user963241
user963241

Reputation: 7048

Creating a menu resource in Android Studio

In Eclipse, the menu resource is created automatically but In Android Studio I've heard you need to create it manually so I copy this function:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.activity_quiz, menu);
    return true;
}

And XML resource:

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

  <item
    android:id="@+id/menu_settings"
    android:orderInCategory="100"
    android:showAsAction="never"
    android:title="@string/menu_settings"/>

</menu>

This doesn't automatically work and shows an error on line android:showAsAction="never".

What's the different with it in Android Studio?

Upvotes: 0

Views: 2131

Answers (1)

Tim
Tim

Reputation: 43364

You're probably using the appcombat library, where showAsAction is in the app namespace, not android namespace. Change to

app:showAsAction="never"

And add xmlns:app="http://schemas.android.com/apk/res-auto" to your menu tag

Upvotes: 1

Related Questions