I'm working on a android application that adds every view programmaticaly.
When the user turns the screen, I just want to values that are filled in to be displayed again.
Is there an easy way to let Android do this automaticaly?
My application is completely dynamic so it doens't have a predetermined layout, which makes it a lot harder.
So, how can I easily save the state of my screen?
Everytime orientation change, android create new view and destroy the old one. You can saved your data when orientation change and re-initialize when the new view is created
Use
onConfigurationChanged
method of activity to detect Orientation ChangeDon't forget to edit the appropriate element in your AndroidManifest.XML like this to include the
android:configChanges
For an expanded explanation of Hein's correct answer see my previous post:
https://stackoverflow.com/a/57239493/5696328