October 2018
Intermediate to advanced
464 pages
15h 17m
English
There are two basic steps here:
As a good programming habit, we define the string in the strings.xml file rather than hard coding it in the XML. We then use the standard Android string identifier to set the title for the menu in step 3. Since this is a Settings menu item, we used the showAsAction="never" option so it wouldn't be shown as an individual menu option in the action bar.
With the menu defined, we will use the menu inflater in step 4 to load the menu during the activity creation. Notice the R.menu.menu_main menu resource syntax? This is why we create the XML in the res/menu directory—so the system will know this is a menu resource.
In step 4, ...