Exam4Training

What two methods you have to override when implementing Android option menus?

What two methods you have to override when implementing Android option menus?
A . onCreateOptionsMenu, onCreateContextMenu
B . onCreateContextMenu, onContextItemSelected
C . onCreateOptionsMenu, onOptionsItemSelected
D . onCreateOptionsMenu, onContextItemSelected

Answer: C

Explanation:

To specify the options menu for an activity, override onCreateOptionsMenu().

When the user selects an item from the options menu (including action items in the app bar), the system calls your activity’s onOptionsItemSelected() method. This method passes the MenuItem selected. You can identify the item by calling getItemId(), which returns the unique ID for the menu item (defined by the android:id attribute in the menu resource or with an integer given to the add() method). You can match this ID against known menu items to perform the appropriate action. For example:

@Override

public boolean onOptionsItemSelected(MenuItem item) {

Etc.

References:

http://developer.android.com/guide/topics/ui/menus.html

Latest AND-401 Dumps Valid Version with 228 Q&As

Latest And Valid Q&A | Instant Download | Once Fail, Full Refund

Exit mobile version