简体   繁体   中英

Android actionbar always showing overflow menu for menu items in actionbar

Hi I am developing sample Android application in which I am trying to display menu items in actionbar. But my actionbar always showing overflow menu even if there is only single menu item. It is not showing my menu items image in action bar. I have implemented this in following manner

    <menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:compat="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    tools:context="com.example.samplechromiapp.MainActivity" >

    <item
        android:id="@+id/categories"
        android:icon="@drawable/navigation_collapse"
        android:showAsAction="ifRoom|withText"  
        android:title="Categories"
        android:visible="true"
        />
</menu>

Am I doing anything wrong? Need some help. Thank you.

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

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

        <item
            android:id="@+id/categories"
            android:icon="@drawable/navigation_collapse"
            android:title="Categories"
            app:showAsAction="always"/>

 </menu>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM