-1

All icons are shown in the overflow menu, but I want them on actionbar view. I have tried several things but still getting the issue. Here is my xml file:

 <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
       <item
          android:id="@+id/addnewqmsmenu"
          app:showAsAction="always"
          android:title="Add New"
          android:icon="@drawable/addqms5"/>
 </menu>
Rajesh Jadav
  • 12,801
  • 5
  • 53
  • 78
shivpal jodha
  • 104
  • 1
  • 9

3 Answers3

1
    <menu xmlns:android="http://schemas.android.com/apk/res/android" 
         xmlns:app="http://schemas.android.com/apk/res-auto" >
    <item
        android:id="@+id/addnewqmsmenu"
        android:icon="@drawable/addqms5"
        android:title="@string/action_settings"
        app:showAsAction="ifRoom"/>

</menu>
IntelliJ Amiya
  • 74,896
  • 15
  • 165
  • 198
1

Try this code and add extra xmlns attribute for your menu and try app:showAsAction instead of android:showAsAction

 <?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/addnewqmsmenu"
            app:showAsAction="always"
            android:title="Add New"
            android:icon="@drawable/addqms5"/>

 </menu>

I hope it will help you.

Rajesh Jadav
  • 12,801
  • 5
  • 53
  • 78
0

Finally i got the answer its because of AppCompatResource . i solved it like that

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


   <item
    android:id="@+id/buttonqms"
    android:title="computer"
    android:showAsAction="always"
    android:icon="@drawable/addqms5"
    tools:ignore="AppCompatResource" />

    </menu>
shivpal jodha
  • 104
  • 1
  • 9