Should onSaveInstanceState keep views "on"?

I have a preference function where I can change the language and theme of my application. From there, I return to the previous action using the back key, and I want to recreate the activity.

I managed to do this by reinitializing the layout in onResume, as well as calling onRestoreInstanceStatefrom there. All views will be restored correctly, if necessary, checked flags, edittexts filled with texts that I previously left there.

But I also have a button that is initially disabled, and only turns on when checking the radio. The problem is this: I check the radio volume, the button turns on. Then I go to settings, change the theme and return to the first action. When I arrive there, the radiator will be restored, as noted, but the button is disabled.

So, it seems that the on / off state is not saved in the bundle, which seems inconsistent. And I did not find any code in the Android source that does this either. Am I missing something, or do I need to write my own code for this?

EDIT: BTW, the state is saved only for views with identifiers. And this button has one, I guarantee that :)

+3
source share
2

, , , , .

:

, , , .

, , . , , , .

:

  • - , onResume,
  • , (, , ) , . , .
  • onSaveInstanceState

, , , , . , .

0

- onResume, .

: PreferenceGroup , , Activity PreferenceActivity.

0

Source: https://habr.com/ru/post/1745936/


All Articles