你好,我可以告诉我代码中缺少的东西, 我有一个动作栏标签,我每次触发标签时都会对内容进行充气,这是我的过程
- >单击选项卡
- >膨胀布局(带虚拟视图的片段)
- >用我的真实内容替换虚拟视图(无addbackstack)
- >单击其他选项卡
- >把应用程序放到后台
然后我收到了这个错误
java.lang.IllegalStateException: Failure saving state: active Programsfragment{43ae6308 id=0x7f090042} has cleared index: -1
在标签
上Tab tabC = actionBar.newTab();
tabC.setText("Programs");
tabC.setTabListener(new TabListener(this, "Programs",
ProgramsFragment.class));
actionBar.addTab(tabC);
on programFragment
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
if (view != null) {
ViewGroup parent = (ViewGroup) view.getParent();
if (parent != null) {System.out.println("sad");
parent.removeView(view);
} else {
ft.detach(pFragment);
ft.attach(pFragment);
//refresh!
ft.replace(R.id.list, pFragment);
ft.addToBackStack(null);
ft.commit();
}
} else {
try {
view = inflater.inflate(R.layout.selection, container, false);
ft.replace(R.id.list, pFragment);
//ft.addToBackStack(null);
ft.commit();
} catch (InflateException e) {
}
}
暂停应用程序因此错误而崩溃
java.lang.IllegalStateException: Failure saving state: active Programsfragment{43ae6308 id=0x7f090042} has cleared index: -1
任何建议或意见都表示赞赏。谢谢。