无法重写ListFragment中的onCreateOptionsMenu [英] Unable to override onCreateOptionsMenu in ListFragment

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

问题描述

我创建了一款支持手机和平板电脑版本的应用程序,因此我使用了android-support-v4.jar库。

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

我的活动扩展了ListFragment,我尝试覆盖onCreateOptionsMenu(Menu Menu,MenuInflater inflater),如下面的链接所示: http://developer.android.com/resources/samples/Support4Demos /src/com/example/android/supportv4/app/FragmentMenuSupport.html

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

我以前叫setHasOptionsMenu。

I previously called setHasOptionsMenu.

不幸的是,我似乎无法重写onCreateOptionsMenu()。

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

这是错误信息:

This is the error message:



类型MyFragment的onCreateOptionsMenu(Menu menu,MenuInflater inflater)方法必须覆盖或实现超类型方法。

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

我做到了这一点:

And I did that with:

Public class MyFragment extends ListFragment


推荐答案

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

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

这篇关于无法重写ListFragment中的onCreateOptionsMenu的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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