Thursday, February 27, 2014

Beginners questions on several events


difference onMenuItemSelected and onOptionsItemSelected, namely at what time to call, how I found out when I click on the menu, both methods are invoked, there onMenuItemClick also called

Why declare the same event so versatile it, I guess I did not understand their true usefulness, therefore I asked

<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
android menu has ContextMenu and OptionsMenu, under normal circumstances, the former long-time pop, which is based on mobile phone hardware menu pops up. Two do not conflict Ha!
Whether pop Context menu or Option menu, click a menu item they will perform onMenuItemSelected.
And onOptionsItemSelected response Option menu click the menu item event.
Thus, a corresponding two menus in response to events (GM), the other only for responding to events Option menu (directional).
The landlord can selectively use, if only need to click on the menu button (Option menu), then you only need to rewrite onOptionsItemSelected method.
Reply:
Oh forgot, there onMenuItemClick event is definitely respond landlord menu item entries are achieved listener OnMenuItemClickListener, so the call will be triggered

No comments:

Post a Comment