[英]Action Button showing up but not overflow menu in Android actionbar
I am a new developer and trying to show action buttons and overflow menu. 我是一名新开发人员,正在尝试显示操作按钮和溢出菜单。 4/6 buttons show in actionBar but i cant see overflow menu with other buttons.
4/6按钮显示在actionBar中,但我看不到带有其他按钮的溢出菜单。 Following is the code
以下是代码
res/menu/menu/menu_activity_action.xml res /菜单/菜单/menu_activity_action.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:myapp="http://schemas.android.com/apk/res-auto" >
<item
android:id="@+id/phone"
android:title="@string/phone"
android:icon="@drawable/phone"
and
myapp:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/computer"
android:title="@string/computer"
android:icon="@drawable/computer"
myapp:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/gamepad"
android:title="@string/gamepad"
android:icon="@drawable/gamepad"
myapp:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/camera"
android:title="@string/camera"
android:icon="@drawable/camera"
myapp:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/video"
android:title="@string/video"
android:icon="@drawable/video"
myapp:showAsAction="ifRoom|withText"
/>
<item
android:id="@+id/email"
android:title="@string/email"
android:icon="@drawable/email"
myapp:showAsAction="ifRoom|withText"
/>
</menu>
mainActivity : 主要活动 :
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_activity_action,menu);
return super.onCreateOptionsMenu(menu);
}
Any idea ?? 任何想法 ??
Try changing to: 尝试更改为:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_activity_action, menu);
return true;
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_activity_action, menu);
return true;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.