Exam4Training

Which of the following is a call-back method that inflates an options menu from file res/menu/menu.xml?

Which of the following is a call-back method that inflates an options menu from file res/menu/menu.xml?
A . onOptionsItemSelected
B . onCreate
C . onCreateMenu
D . onCreateOptionsMenu

Answer: D

Explanation:

To specify the options menu for an activity, override onCreateOptionsMenu() (fragments provide their own onCreateOptionsMenu() callback). In this method, you can inflate your menu resource (defined in XML) into the Menu provided in the callback. For example:

@Override

public boolean onCreateOptionsMenu(Menu menu) {

MenuInflater inflater = getMenuInflater();

inflater.inflate(R.menu.game_menu, menu);

return true;

}

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