In the new update Google has released a new API support library, that supports the ActionBar in API level 7+.
I used ActionBarSherlock until this update and I wrote the code to load the menu:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.activity_main, menu);
return true;
}
and the menu file:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/item_menu_ok" android:icon="@drawable/ic_action_ok"
android:title="@string/ok" android:showAsAction="always"></item>
<item android:id="@+id/item_menu_cancel" android:icon="@drawable/ic_action_cancel"
android:title="@string/cancel" android:showAsAction="always"></item>
</menu>
To set up the menu buttons on the action bar. This code worked perfectly with ActionBarSherlock. But when I changed the action bar to the new support library, the buttons are not shown in the action bar. Even if they are set as android:showAsAction="always"
. And when I debug the code, the function menu.getSize()
return 2, and that is correct, but no buttons are shown..
Why are the buttons not shown in the new support library?
question from:
https://stackoverflow.com/questions/17881547/android-support-v7-with-actionbaractivity-no-menu-shows 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…