onCreateOptionsMenu不会被调用 [英] onCreateOptionsMenu is never called

查看:973
本文介绍了onCreateOptionsMenu不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些麻烦的选项菜单中的Andr​​oid工作。我以前构建应用程序,他们都工作得很好,但现在的菜单只是没有弹出。

I am having some trouble getting an options menu working in Android. I build apps before, and they all worked fine, but now the menu just doesn't pop up.

在code:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    super.onCreateOptionsMenu(menu);

    getMenuInflater().inflate(R.menu.activity_video, menu);
    return true;
}

整个方法从来没有所谓的(通过设置一个断点检查)。该活动是超级简单,它只是有一个 VideoView 在里面,用 OnTouchListener 设置。

the whole method is never even called (checked by setting a breakpoint). The activity is super-simple, it just has a VideoView in it, with an OnTouchListener set.

我使用的是Android 4.0.4上的三星Galaxy 10.1,API级别15,minSDK 15.我失去了一些东西?

I am using Android 4.0.4 on a Samsung Galaxy 10.1, API level 15, minSDK 15. Am I missing something?

推荐答案

如果您测试的手机有onCreateOptionsMenu wont't算得上下手为主题的菜单按钮:

If the phone you test on has a menu button onCreateOptionsMenu wont't be called on start with the theme:

安卓主题=@安卓风格/ Theme.Black.NoTitleBar

但是,当你点击菜单按钮 onCreateOptionsMenu 将被调用。我不知道在手机上发生的事情没有硬件按钮...

But when you click the menu button the onCreateOptionsMenu will be called. I don't know what happens on phones without hardware buttons...

这篇关于onCreateOptionsMenu不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆