The ActionBar does not display the menu item. How to display it?

In the markup file for the menu, I wrote 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" xmlns:tools="http://schemas.android.com/tools" tools:context="test.prog1.MainActivity"> <item android:title="@string/action_liked" android:id="@+id/action_liked" android:icon="@android:drawable/btn_star_big_off" android:showAsAction="always" /> <item android:id="@+id/action_about" android:orderInCategory="100" android:title="@string/action_about" app:showAsAction="never" /> </menu> 

action_liked - needs to be displayed. It only appears in the dropdown menu.

    1 answer 1

    You are using the wrong namespace for the showAsAction attribute showAsAction the first menu item.

    Replace android:showAsAction="always" with app:showAsAction="always" .

    • helped, thanks. - Sergey
    • And how after clicking on this item from the program to replace the icon in this menu item? - Sergey
    • ok .. I can’t do it in only 7 minutes I can - Sergey
    • @Sergey, StackOverflow is not a forum, it is a QA: one question - one answer. If you have a new question - create a new question. - post_zeew
    • 40 minutes to wait need for this ( - Sergey