android - Fragment changes on rotation with navigation drawer -


current scenario

in app having navigation drawer fragments. works fine in portrait mode.

problem

suppose when in portrait mode select second item navigation drawer. loads when rotate phone landscape mode, first fragment navigation menu gets loaded instead of second.

i know have save instance fragment don't know how , should in main activity or in fragment itself

you should in fragment.

just follow these links:

android - save/restore fragment state

or perhaps:

once all, how correctly save instance state of fragments in stack?

also, let's mention onrestoreinstancestate, fragment's doesn't have method.so, should use onactivitycreated receives bundle saved instance state (or null).

take @ docs:

http://developer.android.com/reference/android/app/fragment.html#onactivitycreated(android.os.bundle)


Comments