Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Ctors](https://developer.android.com/reference/android/view/MenuInflater#pubctors) \| [Methods](https://developer.android.com/reference/android/view/MenuInflater#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/view/MenuInflater#inhmethods)

# MenuInflater

*** ** * ** ***

` public class MenuInflater `   
` extends https://developer.android.com/reference/java/lang/Object ` ` `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.view.MenuInflater |

<br />

*** ** * ** ***

This class is used to instantiate menu XML files into Menu objects.

For performance reasons, menu inflation relies heavily on pre-processing of XML files that is done at build time. Therefore, it is not currently possible to use MenuInflater with an XmlPullParser over a plain XML file at runtime; it only works with an XmlPullParser returned from a compiled resource (R. *something* file.)

## Summary

| ### Public constructors ||
|---|---|
| ` https://developer.android.com/reference/android/view/MenuInflater#MenuInflater(android.content.Context)(https://developer.android.com/reference/android/content/Context context) ` Constructs a menu inflater. |

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/view/MenuInflater#inflate(int,%20android.view.Menu)(int menuRes, https://developer.android.com/reference/android/view/Menu menu) ` Inflate a menu hierarchy from the specified XML resource. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.

## Public constructors

### MenuInflater

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public MenuInflater (Context context)
```

Constructs a menu inflater.

<br />

| Parameters ||
|---|---|
| `context` | `Context` <br /> |

**See also:**

- `https://developer.android.com/reference/android/app/Activity#getMenuInflater()`

## Public methods

### inflate

Added in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void inflate (int menuRes, 
                Menu menu)
```

Inflate a menu hierarchy from the specified XML resource. Throws `https://developer.android.com/reference/android/view/InflateException` if there is an error.

<br />

| Parameters ||
|---|---|
| `menuRes` | `int`: Resource ID for an XML layout resource to load (e.g., `R.menu.main_activity`) <br /> |
| `menu` | `Menu`: The Menu to inflate into. The items and submenus will be added to this Menu. <br /> |