在ActionBarCompat项目在溢出始终表现 [英] Items in ActionBarCompat are showed always in Overflow

查看:170
本文介绍了在ActionBarCompat项目在溢出始终表现的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用ActionBarCompat在我的应用程序中,我要显示在操作栏中的一个或两个项目

I'm using ActionBarCompat in my app, an I want to show one or two items in the action bar

我follwed的谷歌开发者的指南,但是当我测试了一下,该项目显示,在溢出选项(在的Nexus 4),如果我点击的菜单按钮,如果存在(例如,银河S3)

I follwed the guide of google developers, but when I test it, the items are showed in the "Overflow" option (in Nexus 4) and if I tap on the menu button if there exist (ex. Galaxy S3)

什么我做错了吗?

溶液中发现的

SOLUTION FOUND

您可以找到它的答案。

推荐答案

我找到了解决办法,所以我贴的回答:

I found the solution so I posted as Answer:

溶液中发现的

在菜单中的XML,你必须把新的命名空间,使actionbarcompat工作。因此,有需要此SPACENAME而不是机器人一些选项。因此,解决方案是这样的:

In the xml of the menu, you have to put the new namespace, to make actionbarcompat work. So there are some options that need this spacename instead of "android". So the solutions is This:

旧登录菜单:

    <item
        android:id="@+id/action_register"
        android:showAsAction="always"
        android:title="@string/login_menu_register"/>

新登录菜单(液)(看看怎么caledshowAsAction)

    <item
        android:id="@+id/action_register"
        shudy:showAsAction="always"
        android:title="@string/login_menu_register"/>

Login.xml(MENU)

<item
    android:id="@+id/action_register"
    android:showAsAction="always"
    android:title="@string/login_menu_register"/>
<item
    android:id="@+id/action_register2"
    android:showAsAction="always"
    android:title="miau"/>

LoginActivity.java

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        SLog.d(CLASS_NAME + " onCreate()");
        setContentView(R.layout.activity_login);
        actionBar = getSupportActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setHomeButtonEnabled(true);
        findViews();
        buttons();

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.login, menu);
        return true;
    }

清单

<application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.DarkActionBar" >
        <activity
            android:name="com.shudy.myworld.LoginActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

这篇关于在ActionBarCompat项目在溢出始终表现的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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