Bigsnake
Bigsnake

Reputation: 15

Android: "Expected resource of type menu" error

I am encountering the error "Expected resource of type menu" with this line of code

    @Override
    public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
        inflater.inflate(R.layout.activity_apps, menu);
    }

However my xml file actvity_apps.xml contains the menu tag and nothing else

<menu xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">

<item
    android:id="@+id/menu_configure_locale"
    android:showAsAction="collapseActionView"
    android:title="@string/menu_configure_locale" />

</menu>

Can someone explain what is going on and how to fix the error?

Upvotes: 0

Views: 551

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006614

Can someone explain what is going on

You put a menu resource in res/layout/, and the build tools will not accept that.

and how to fix the error?

Move the file from res/layout/ to res/menu/. You may need to create the res/menu/ directory.

Upvotes: 1

Related Questions