Call listview selected item click, Using Android menu item
In my android application I have a listview with set of records. I have implemented the OnItemClickListener and set it to the listview. So when user click any listview Item it redirects to next activity and do the stuff I need.
The problem is, I have to implement the same functionality to be performed using android Menu.(When click menu button). When click menu button it displays a menu item, to perfo开发者_运维知识库rm Listviews focused item to call click event. Simply when click menu item it should perform the the focused listview item click, as when we normally click the listview item.
Have no idea of how to call click event
Can anyone guide me how to do this please....
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.new_game:
newGame();
return true;
case R.id.help:
showHelp();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
Taken from http://developer.android.com/guide/topics/ui/menus.html.
精彩评论