0
我得到一个编译时错误The method getLastCustomNonConfigurationInstance() of type TopRatedFragment must override or implement a supertype method
型片段的方法,必须重写或实现超方法
TopRatedFragment.java:
public class TopRatedFragment extends Fragment {
private CurlView mCurlView;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_top_rated, container, false);
int index = 0;
if (getLastCustomNonConfigurationInstance() != null) {
index = (Integer) getLastCustomNonConfigurationInstance();
}
mCurlView = (CurlView)rootView.findViewById(R.id.curl);
mCurlView.setPageProvider(new PageProvider());
mCurlView.setSizeChangedObserver(new SizeChangedObserver());
mCurlView.setCurrentIndex(index);
mCurlView.setBackgroundColor(0xFF202830);
return rootView;
}
@Override
public Object getLastCustomNonConfigurationInstance() { ---> getting compile error
return mCurlView.getCurrentIndex();
}
我做的动作栏选项卡的页面卷曲所以我只是将FragmentActivity代码传递给Fragment。 getLastCustomNonConfigurationInstance()
方法属于FragmentActivity.Thats为什么我得到错误。
我不知道如何以正确的方式解决这个错误。任何人都可以帮助我解决这个问题。
编辑︰我明确需要该方法。顺便说一句如果删除覆盖,然后在运行时得到空指针异常。
谢谢you.Hope休息。 – Steve 2014-11-24 06:20:01