I have a fragment, which hold some EditTexts
, some RadioGroups
and Spinners
.
When I change the orientation the view state isn't retained.
I tried to override onSavaInstanceState
and call setRetainInstance(true)
, but it doesn't helped.
I also tried to save all inserted values in the Bundle outState
like this: outState.putString("name", mName.getText().toString())
and restore it in onCreateView
.
Doesn't helped either, the Bundle outState
in onCreateView
hold the values, but I can't manipulate the views to set the value to it. For example like this: mName.setText(savedInstanceState.getString("name"))
Any ideas how to solve it?
I had replaced the Fragment
in the FragmentActivity
, this caused tha fact that the state wasn't restored properly.
I surrounded the Fragment
committing with if (savedInstanceState == null)
in the onCreate
method.
Also I used the Bundle outState
and onSaveInstanceState
of the Fragment
to restore the state in tha same Fragment
properly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.