CHAPTER 7: Making Apps Interactive: Intents, Event Handling, and Menus 215
The class hierarchy for the MenuInflater class is structured as follows, and this class was created
“from scratch” from the Java Object master class specifically to inflate Menu objects using XML
definition files stored in the /res/menu folder:
java.lang.Object
android.view.MenuInflater
It is interesting to note that you do not need to use an import android.view.MenuInflater;
statement at the top of your MainActivity.java class because there is a method which is part
of the android.app.Activity package called getMenuInflater( ) which provides access to the
MenuInflater class’s .inflate( ) method by using something called Java method “chaining” using the
getMenuInflater( ).inflate( ) Java code construct. As you will see later on in the code which we will
be writing in this chapter, the dot or period character chains the two Java methods together.
Designing Menus in XML Using