不可能覆盖onCreateOptionsMenu在ListFragment不可能、onCreateOptionsMenu、ListFragment

2023-09-05 06:09:06 作者:我若不猖狂谁能替我坚强

我创建一个同时支持手机和平板电脑版的应用程序,所以我使用了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充气)喜欢这里: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.

 
精彩推荐
图片推荐