0

I wrote in activity

   public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.add_action,menu);
    return super.onCreateOptionsMenu(menu);
}

I wrote in menu file

<item
    android:id="@+id/add"
    android:showAsAction="ifRoom"
    android:icon="@drawable/ic_add_circle_outline_black_24dp"
    android:title="@string/add"
   />

The error is still showing, any ideas ?

enter image description here

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142

3 Answers3

0

Assuming that this is your only icon, change ifRoom to always. it is not recommended.

If that does not help, add this line to the top of your menu

xmlns:app="http://schemas.android.com/apk/res-auto"

Zun
  • 1,553
  • 3
  • 15
  • 26
0

Try this

<?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto" >

    <item
        android:id="@+id/add"
        android:showAsAction="always"
        android:title="@string/add"
        android:icon="@drawable/ic_add_circle_outline_black_24dp"
        app:showAsAction="always"/>

    </menu>
Vipin Sharma
  • 594
  • 5
  • 19
0

You need to add

app:showAsAction="always"

Add image to res/drawable/Alt-Tag-android-popup-menu-in-android.

Amit Vaghela
  • 22,772
  • 22
  • 86
  • 142