nerdexam
Android

AND-401 · Question #117

Consider the following code : @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo)…

The correct answer is B. The code creates menu items for context menu programmatically. See the full explanation below for the reasoning.

Question

Consider the following code :

@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); menu.setHeaderTitle("Menu"); AdapterContextMenuInfo cmi = (AdapterContextMenuInfo) menuInfo; menu.add(1, cmi.position, 0, "Open file"); menu.add(2, cmi.position, 0, "Save file");} Which of the following best explains the code above?

Options

  • AThe code inflates an xml file into menu items.
  • BThe code creates menu items for context menu programmatically.
  • CThe code assign actions to menu items.
  • DThe code Opens a menu resource file, modifies it, and saves the changes.

How the community answered

(20 responses)
  • A
    5% (1)
  • B
    75% (15)
  • C
    5% (1)
  • D
    15% (3)

Community Discussion

No community discussion yet for this question.

Full AND-401 Practice