I recently worked with ActionBarSherlock, and following various tutorials, I wrote this code to add items to the action bar
@Override public boolean onCreateOptionsMenu(Menu menu) { menu.add("Refresh") .setIcon(R.drawable.ic_action_refresh) .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS); menu.add("Search")
However, I do not know how to distinguish two clicks.
Although I found out that you need to override onOptionsItemSelected to handle clicks, and that the switch statement can be used to distinguish clicks, most manuals use element identifiers from their XML menus. Since I am not creating a menu in xml, how can I distinguish clicks without identifiers.
source share