不可能覆盖onCreateOptionsMenu在ListFragment [英] Impossible to override onCreateOptionsMenu in ListFragment

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

问题描述

我创建一个同时支持手机和平板电脑版的应用程序,所以我使用了Android支持-v4.jar库。

I create an app that supports both phone and tablet version so i use the android-support-v4.jar library.

我的活动来延长ListFragment,我要尽量覆盖onCreateOptionsMenu(菜单菜单,MenuInflater充气)喜欢这里:<一href="http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentMenuSupport.html">http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentMenuSupport.html

My activity extends the ListFragment and I try to override the onCreateOptionsMenu(Menu menu, MenuInflater inflater) like here: http://developer.android.com/resources/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentMenuSupport.html

我previously称为setHasOptionsMenu。

I previously called setHasOptionsMenu.

不幸的是,似乎我不能重写onCreateOptionsMenu()!!

Unfortunately, it seems that I cannot override onCreateOptionsMenu()!!

它不断告诉我:

该方法onCreateOptionsMenu的(功能菜单,MenuInflater充气)   键入MyFragment必须覆盖或实现超类型的方法。

The method onCreateOptionsMenu(Menu menu, MenuInflater inflater) of type MyFragment must override or implements a supertype method.

和我这样做,有:

Public class MyFragment extends ListFragment

我在这里完全失去了..感谢很多的任何帮助。

I am completely lost here.. Thank a lot for any help.

推荐答案

确认的进口从兼容性库,而不是从SDK本身。

Make sure the imports are from the compatibility library and not from the SDK itself.

这篇关于不可能覆盖onCreateOptionsMenu在ListFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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