Using compat lib v1 (not using v2|3 because of certain bugs); a variation of this question.
I have a fragment whose UI has various controls whose state I want to maintai
If you use setRetainInstance(true)
then of course the bundle is null. The fragment is not destroyed but only detached from the current activity and attached to the new activity. Only when the fragment is destroyed do you get a bundle with the values you saved in onSaveInstanceState
. Just remove setRetainInstance(true)
and use the saved values in onCreateView() to setup your custom views.