Android的onCreateOptionsMenu不显示 [英] Android onCreateOptionsMenu is not displaying
本文介绍了Android的onCreateOptionsMenu不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的Android活动中,我使用这个主题删除操作栏
In my android activity, i removed the Action Bar by using this Theme
<style name="Theme.NoTitle" parent="@android:style/Theme.NoTitleBar"></style>
但我的问题是onCreateOptionsMenu不显示,我试过这个方法来创建
那请参阅
but my problem is "onCreateOptionsMenu" is not display, I tried this method to create that pls see
private void getOverflowMenu()
{
try
{
ViewConfiguration config = ViewConfiguration.get(Home.this);
Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
if (menuKeyField != null)
{
menuKeyField.setAccessible(true);
menuKeyField.setBoolean(config , false);
}
} catch (Exception e)
{
e.printStackTrace();
}
}
在此onCreateOptionsMenu不显示。请大家帮我
in this "onCreateOptionsMenu" is not displaying. please help me
但它在三星显示
因为:三星手机具有自己的硬件菜单键,而不是在关系等等
Because: in Samsung mobile has its own hardware menu button, but not in nexus etc
请参阅图片
推荐答案
我终于得到了答案
在我的的AndroidManifest.xml 我只是删除这一行
in my AndroidManifest.xml i just removed this line
android:targetSdkVersion="18"
这篇关于Android的onCreateOptionsMenu不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文