问题
I run into a problem while I was settings up the Preferences for my App
.
I would like to have a Button in the ActionBar
(e.g. Save) but my ActionBar
is not showing anything. I put this Line in the onCreate
Method:
this.setHasOptionsMenu(true)
;
And implemented the
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
public boolean onOptionsItemSelected(MenuItem item)
methods as well. However, it does not show anything.
回答1:
Be sure your button item in your action menu layout something like:
<item
android:id="@+id/action_save"
android:orderInCategory="1"
your_icon:showAsAction="always"
android:icon="@drawable/icon_save"
/>
来源:https://stackoverflow.com/questions/23754483/create-an-actionbar-optionsmenu-in-an-preferencefragment