我有一个listAdapter,当我点击其中一个子视图时,有时候(RARELY),我得到以下异常:
java.lang.IllegalStateException: Can not perform this action after onSaveInstanceState.
代码:
@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;
}
现在,我已经了解了状态丢失(http://www.androiddesignpatterns.com/2013/08/fragment-transaction-commit-state-loss.html),我知道我应该避免在异步回调方法中执行事务。 但是,在这种情况下,我别无选择。