本文介绍了在PreferenceFragment中创建一个Actionbar OptionsMenu的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
设置App
的首选项时遇到问题.
I run into a problem while I was settings up the Preferences for my App
.
我想在ActionBar
中有一个按钮(例如,保存),但是我的ActionBar
没有显示任何内容.我将此行放在onCreate
方法中:
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)
;
并实施了
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater)
public boolean onOptionsItemSelected(MenuItem item)
方法也是如此.但是,它什么也没显示.
methods as well. However, it does not show anything.
推荐答案
请确保操作菜单中的按钮项布局如下:
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"
/>
这篇关于在PreferenceFragment中创建一个Actionbar OptionsMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!