Android操作按钮被推入溢出状态

时间:2014-06-18 22:38:44

标签: android android-actionbar

我关注Android开发者指南。我有这个菜单,我在操作栏中充气:

RES /菜单/ main_activity_actions.xml

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
    <!--Search, should appear as action button -->
    <item android:id="@+id/action_search"
        android:icon="@drawable/ic_action_search"
        android:title="@string/action_search"
        android:showAsAction="always" />

    <!-- Settings, should always be in overflow -->
    <item android:id="@+id/action_settings"
        android:title="@string/action_settings"
        android:showAsAction="never"/>
</menu>

我在res / drawable中有一个相应的图标,并且像这样膨胀:

   @Override
    public boolean onCreateOptionsMenu(Menu menu) {

        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main_activity_actions, menu);
        return true;
    }

我遇到的问题是search操作被推入溢出,我无法弄清楚如何将其设置为始终显示在操作栏中的操作按钮

虽然有很多相关问题,但我没有找到重复的问题。

0 个答案:

没有答案