我是一名新开发人员并尝试显示操作按钮和溢出菜单。 4/6按钮显示在actionBar但我看不到溢出菜单与其他按钮。以下是代码
res / menu / menu / 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);
}
任何想法?
答案 0 :(得分:0)
尝试更改为:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_activity_action, menu);
return true;
}
答案 1 :(得分:0)
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_activity_action, menu);
return true;
}