问题描述
我有与一个标签式界面自定义的滑动菜单的活动。出于某种原因,我的一个片段(也是唯一一个)有这个错误,我似乎无法找到它在做什么。
I've got an Activity with a custom sliding menu for a tab-like interface. For some reason, one (and only one) of my fragments has this error and I can't seem to find what it's doing.
下面是堆栈跟踪。
E/FragmentManager(13024): Failure saving state: active SettingsFragment{427b2918} has cleared index: -1
E/FragmentManager(13024): Activity state:
E/AndroidRuntime(13024): FATAL EXCEPTION: main
E/AndroidRuntime(13024): java.lang.IllegalStateException: Failure saving state: active SettingsFragment{427b2918} has cleared index: -1
E/AndroidRuntime(13024): at android.support.v4.app.FragmentManagerImpl.saveAllState(FragmentManager.java:1700)
E/AndroidRuntime(13024): at android.support.v4.app.FragmentActivity.onSaveInstanceState(FragmentActivity.java:527)
E/AndroidRuntime(13024): at com.actionbarsherlock.app.SherlockFragmentActivity.onSaveInstanceState(SherlockFragmentActivity.java:127)
E/AndroidRuntime(13024): at com.slidingmenu.lib.app.SlidingFragmentActivity.onSaveInstanceState(SlidingFragmentActivity.java:50)
E/AndroidRuntime(13024): at com.client.activities.BaseMenuActivity.onSaveInstanceState(BaseMenuActivity.java:139)
该片段是超级简单。它是所有子类SherlockFragment并重写onCreateView和onActivityCreated设置视图。它有一些按钮,导航到其他片段。
The fragment is super simple. All it does is subclass SherlockFragment and override onCreateView and onActivityCreated to setup the view. It's got some buttons that navigate to other fragments.
我甚至无法可靠地重现此错误。任何想法?
I can't even reliably reproduce this error. Any ideas?
推荐答案
在这种情况下,我想,当你想连接你的片段,它见过像我的code
in this case i Guess when you want to attach you're fragment , it seen like my code
case 2:
ft.replace(R.id.content_frame, **xxxx**, "2");
ft.detach(**yyyyyyy**);
ft.attach(**yyyyyyy**);
code以下是错误的,正确的code是
code below is wrong and correct code is
case 2:
ft.replace(R.id.content_frame, **xxxx**, "2");
ft.detach(**xxxx**);
ft.attach(**xxxx**);
也许你有这样的错误,我希望对你有所帮助。
maybe you have error like this and i hope it be helpful for you
这篇关于什么是活性片段已被清除指数:-1意思,如何解决呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!