First of all I would mention that I've googled for this error a long time and I find lots of solutions, but non of them helped me.
My problem is that I have a slideshow (realized with horizontal scrollview) in the upper half of my screen and a gridview in the lower half. When I first start the app, clicks on the slideshow throwing an exception: IllegalStateException: Can not perform this action after onSaveInstanceState
The LogCat shows me, that this happens, when the fragmentmanager tries to change the fragment with the "commit()" Method. I already tried the "commitAllowingStateLoss()"-Method, but then I get an "Activity has been destroyed"-Exception - also at the same line, where the Fragment Manager tries to commit the changes.
Instead if I click at one of the gridtiles in the gridview, the fragment manager switches the content, without any problems. This seems to me a strange behaviour, because the slideshow and the gridview are part of the same fragment and for one the fragment manager can switch the content and one time not?
Can anyone explain this behaviour and help me understand my error? Heres some code:
part of the switchContent Method, that switches the fragments:
ft.replace(R.id.fragment_container, fragment, tag);
fragment.setCustomTag(tag);
ft.commit();
Click on Slideshow is detected by gesture detector:
@Override
public boolean onSingleTapConfirmed(MotionEvent e) {
Point position = convertPositions();
Bundle b = new Bundle();
b.putLong(Constants.BUNDLE_ID, getCurrentId());
b.putInt(Constants.BUNDLE_POSITON, position.y);
((NavigationActivity) getContext()).switchContent(
Constants.TAG_FRAGMENT, b, false);
return true;
}
And click on tiles of the gridview is detected by a normal onClickListener:
gridview.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(android.widget.AdapterView<?> arg0, View v,
int position, long arg3) {
Bundle b = new Bundle();
b.putLong(Constants.BUNDLE_ID, id);
b.putInt(Constants.BUNDLE_R_POSITION, position);
context.switchContent(Constants.TAG_FRAGMENT2, b, refresh);
}});
Thanks in advance ;)