219k views
1 vote
Which statement within the class for a fragment indicates that the fragment contains menu items to contribute to the options menu for the activity?

A. setHasOptionsMenu(true);
B. onCreateOptionsMenu(Menu menu, MenuInflater inflater)
C. onOptionsItemSelected(MenuItem item)
D. onCreateOptionsMenu(Menu menu)

User Sange
by
8.5k points

1 Answer

2 votes

Final answer:

The statement within the class for a fragment that indicates the fragment contains menu items to contribute to the options menu for the activity is setHasOptionsMenu(true).

Step-by-step explanation:

The statement within the class for a fragment that indicates the fragment contains menu items to contribute to the options menu for the activity is A. setHasOptionsMenu(true);. This method is used to inform the Android system that the fragment has menu items that should be added to the options menu of the activity. By calling this method with the argument of true, the fragment will receive a call to the onCreateOptionsMenu(Menu menu) method.

User Sazzad
by
8.3k points