문제

I'm developing a rather GUI heavy android app and it has lots of little widgets (text fields, buttons etc..) which are dynamically configured at runtime. Everything is working well enough when the application has focus however once the user pushes the app to the background and restore it, all the widgets lose their dynamic state and revert back to their default state defined by their layout. Is this the proper behavior of Android apps?

I've developed numerous UIs on other platforms (iOS, Windows, Mac) and I've never seen behavior like this.. Do i have to do some magic dance to make Android keep the widgets state between re-focus? Any tips would be appreciated thanks!

도움이 되었습니까?

해결책

What you need to do is to look at the lifecycle of an activity.

Basically, you need to save state in an onPause() function, and restore it with an onResume() function.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top