Android ListAdapter中的IllegalStateException';s onChildClick
我有一个listAdapter,当我单击它的一个子视图时,有时(尽管很少),我会得到以下异常:Android ListAdapter中的IllegalStateException';s onChildClick,android,illegalstateexception,Android,Illegalstateexception,我有一个listAdapter,当我单击它的一个子视图时,有时(尽管很少),我会得到以下异常: java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState. 代码: 现在,我已经阅读了state loss(),我知道应该避免在异步回调方法中执行事务。 但是,在这种情况下,我别无选择。您是否尝试过使用commitAllowingStateLoss()而不是commit()?嗯,我可以
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState.
代码:
现在,我已经阅读了state loss(),我知道应该避免在异步回调方法中执行事务。
但是,在这种情况下,我别无选择。您是否尝试过使用commitAllowingStateLoss()而不是commit()?嗯,我可以。但由于强烈建议避免这种情况,我正在寻找一种更“更好的实践”的解决方案。如果有,那就是。谢谢
@Override
public boolean onChildClick( ExpandableListView parent, View view, int groupPosition, int childPosition, long id )
{
OBJ obj = objListAdapter.getChild(groupPosition, childPosition);
mFragmentManager.beginTransaction().
addToBackStack(null).
setCustomAnimations(R.animator.fragment_fade_in, R.animator.fragment_fade_out, R.animator.fragment_fade_in, R.animator.fragment_fade_out).
add(R.id.mainActFrmFragmentContainerBack,
ObjDisplayfragment.getFragment(......),ObjDisplayfragment.TAG).commit();
return false;
}