Android Application Development (AND-401) — Question 92
Consider the following the code:
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.game_menu, menu);
return true;
}
Which of the following is true about the code above?
Answer options
- A. The code is auto generated and should not be edited
- B. This method handles clicks and assign actions to menu items
- C. This function inflates an XML file in the res/menu folder into menu items
- D. This method inflates an XML file in the res/layout folder into layout.
Correct answer: C
Explanation
The correct answer is C because the code specifically inflates the XML file from the res/menu folder into menu items. Option A is incorrect as the code can be modified; option B is wrong because this method does not handle click events; option D is false since it refers to the wrong directory for inflating layout files.