在动作条菜单项的Andr​​oid动作条总是显示溢出菜单 [英] Android actionbar always showing overflow menu for menu items in actionbar

查看:169
本文介绍了在动作条菜单项的Andr​​oid动作条总是显示溢出菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好我正在开发中,我试图显示动作条菜单项样本Android应用程序。但是我的动作条处处流露出哪怕只有一个菜单项溢出菜单。它没有显示在操作栏我的菜单项的形象。我在下面的方式实现这一

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.

推荐答案

试试这个code和添加额外的的xmlns 属性,您的菜单,并尝试应用:showAsAction 而不是的android:showAsAction

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>

这篇关于在动作条菜单项的Andr​​oid动作条总是显示溢出菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆