public boolean onCreateOptionsMenu(Menu menu)
{
getMenuInflater().inflate(R.menu.quiz, menu);
return true;
}
here in R.menu.quiz the menu is underlined…how to fix this? i don’t understand the inflator and why is it used here
Hello,
R.menu is Menu Resource xml file. it is in the res/menu/quiz.xml folder. Also, you should know what R is. (For example, R.color, R.string, R.layout etc.)
R is a class containing the definitions for all resources of a particular application package.
Therefore,
you must create the xml file in res/menu. if menu file is not shown, you must create it also.
For the More Curious: link Android Dev.
and "inflater " is
a view means taking the layout XML and parsing it to create the view and viewgroup objects from the elements and their attributes specified within, and then adding the hierarchy of those views and viewgroups to the parent ViewGroup.
If you haven’t fixed this problem yet, I recommend deleting the onCreateOptionsMenu
method entirely. This is for a menu and you’ll learn all about how that works later in the book.
Deleting that method along with onOptionsItemSelected
(if you have it), should allow you to move on without a menu.