Android的动作条项目的三个点 [英] Android Actionbar items as three dots

查看:130
本文介绍了Android的动作条项目的三个点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的主要活动(RES /菜单/ main_menu.xml)菜单,我想在动作条只有一个项目,其余应在三个点菜单隐藏。

现在的问题是,我从来没有看到我的动作条的三个点的项目。为什么我不能看到三个点的项目?如何强制项目将在其下隐藏的?

注:我用的minSdkVersion =14,我测试的AVD

解决方案

 < XML版本=1.0编码=UTF-8&GT?;
<菜单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android>

    <项目机器人:ID =@ + ID / menu_item_share
        机器人:标题=@字符串/股
        机器人:图标=@机器人:可绘制/ ic_menu_share
        机器人:showAsAction =ifRoom
        机器人:actionProviderClass =android.widget.ShareActionProvider/>

    <项目
        机器人:ID =@ + ID /空
        机器人:标题=@字符串/选项
        机器人:orderInCategory =101
        机器人:showAsAction =总是
        机器人:图标=@可绘制/ ic_action_overflow>

        <菜单>

            <项目机器人:ID =@ + ID / action_settings
                机器人:图标=@机器人:可绘制/ ic_menu_ preferences
                机器人:showAsAction =ifRoom
                机器人:标题=@字符串/设置/>

            <项目机器人:ID =@ + ID / action_help
                机器人:图标=@机器人:可绘制/ ic_menu_help
                机器人:showAsAction =ifRoom
                机器人:标题=@字符串/帮助/>

        < /菜单>

    < /项目>

< /菜单>
 

您需要将 ic_action_overflow 图标,一旦你添加到您的 RES /绘制... 文件夹下载他们从这里开始:<一href="http://developer.android.com/design/downloads/index.html">http://developer.android.com/design/downloads/index.html

I have a menu for my main activity (res/menu/main_menu.xml) and I want only one item on the Actionbar and the rest shall be hidden under three dots menu.

The problem is, I never see the three dots item on my actionbar. Why I can't see three dots item? How to force items to be hidden under it?

Note: I use minSdkVersion="14" and I test in AVD.

解决方案

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

    <item android:id="@+id/menu_item_share"
        android:title="@string/share"
        android:icon="@android:drawable/ic_menu_share"
        android:showAsAction="ifRoom"
        android:actionProviderClass="android.widget.ShareActionProvider" />

    <item
        android:id="@+id/empty"
        android:title="@string/options"
        android:orderInCategory="101"
        android:showAsAction="always"
        android:icon="@drawable/ic_action_overflow">

        <menu>

            <item android:id="@+id/action_settings"
                android:icon="@android:drawable/ic_menu_preferences"
                android:showAsAction="ifRoom"
                android:title="@string/settings" />

            <item android:id="@+id/action_help"
                android:icon="@android:drawable/ic_menu_help"
                android:showAsAction="ifRoom"
                android:title="@string/help" />

        </menu>

    </item>

</menu>

You will need to add the ic_action_overflow icons to your res/drawable... folders once you've downloaded them from here: http://developer.android.com/design/downloads/index.html

这篇关于Android的动作条项目的三个点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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