为什么菜单项出现在optionsMenu? [英] Why the menu items appear on the optionsMenu?
问题描述
尽管也有一定的作用相关的一些图标,并且在动作条
,它们出现在 optionsMenu $ C $没有足够的空间C>,而不是出现在
溢
图标。
Despite there are some icons associated with certain action and have no enough space in the Actionbar
, they appear in the optionsMenu
instead of appearing in the overflow
icon.
我膨胀的动作条
有五个图标,每个人都有一个特定的功能请参阅下面的XML文件,其中有 Android的:showAsAction =从不
我希望他们含蓄地驻留在溢
图标里面的动作条
,但是当我运行的应用程序,任何项目物业安卓showAsAction =从不
而是出现在 optionsMenu
。为什么出现这种情况?我希望我清楚地说明了问题。
I am inflating the actionBar
with five icons each one has a specific functionality "Please refer to the XML file below", the items which have the android:showAsAction=never
I expect them to implicitly reside inside the overflow
icon on the actionBar
, but when I run the App, any item with the property android:showAsAction=never
instead it appears in the optionsMenu
. Why that happens? and I hope i explained the problem clearly.
更新的
Update:
简单地说,我想,如果没有空间的图标放置在动作条
,它们应该放在溢出里面
如图所示,在三纵点在彼此的图标的图标。
Simply, I want, if there is no space for the icon to be placed on the ActionBar
, They should be placed inside the overflow
icon as shown in the image " the icon with three vertical dots over each other".
要注意
我使用的银河注3
为什么我的问题被标记为重复。建议为重复的问题比我的不同?请重新审查这个问题。
Why my question is marked as a duplicate. The question suggested as a duplicate is different than mine? Please review the question again.
JAVA_ code 的
Java_Code:
public class ActionBarActivityTest00 extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_action_bar_activity_test00);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.action_bar_activity_test00, menu);
return super.onCreateOptionsMenu(menu);
}
XML 的
XML:
<menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.actionbaractivitytest.ActionBarActivityTest00" >
<!-- Search / will display always -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="action_search"
android:showAsAction="ifRoom"/>
<!-- Location Found -->
<item android:id="@+id/action_location_found"
android:icon="@drawable/ic_action_location_found"
android:title="action_location_found"
android:showAsAction="ifRoom" />
<!-- Refresh -->
<item android:id="@+id/action_refresh"
android:icon="@drawable/ic_action_refresh"
android:title="action_refresh"
android:showAsAction="ifRoom" />
<!-- Help -->
<item android:id="@+id/action_help"
android:icon="@drawable/ic_launcher"
android:title="action_help"
android:showAsAction="never"/>
<!-- Check updates -->
<item android:id="@+id/action_check_updates"
android:icon="@drawable/ic_action_refresh"
android:title="action_check_updates"
android:showAsAction="never" />
推荐答案
试试这个:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.fafad.MainActivity" >
<!-- Search / will display always -->
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="action_search"
android:orderInCategory="1"
app:showAsAction="ifRoom"/>
<!-- Location Found -->
<item android:id="@+id/action_location_found"
android:orderInCategory="2"
android:icon="@drawable/ic_action_location_found"
android:title="action_location_found"
app:showAsAction="ifRoom" />
<!-- Refresh -->
<item android:id="@+id/action_refresh"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="3"
android:title="action_refresh"
app:showAsAction="ifRoom" />
<!-- Help -->
<item android:id="@+id/action_help"
android:icon="@drawable/ic_launcher"
android:orderInCategory="4"
android:title="action_help"
android:showAsAction="never"/>
<!-- Check updates -->
<item android:id="@+id/action_check_updates"
android:icon="@drawable/ic_action_refresh"
android:orderInCategory="5"
android:title="action_check_updates"
app:showAsAction="never" />
</menu>
这篇关于为什么菜单项出现在optionsMenu?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!