开发者

Android Development: How To Keep Text When Orientation Changes?

开发者 https://www.devze.com 2023-01-26 00:17 出处:网络
开发者_运维问答In my app I have a TextView that I use setText on after a certain action. But when the orientation changes the TextView\'s text is changed back to normal.

开发者_运维问答In my app I have a TextView that I use setText on after a certain action. But when the orientation changes the TextView's text is changed back to normal.

I have a similar problem with my app's file browser, for some reason it goes back to /sdcard/ when the orientation changes :/

Is there anything I can do to prevent loosing the TextView's text?


Store all your view's contents in onSaveInstanceState() and reload it in onCreate(). If you want to be funny and have all those values persist even after a system reboot, you could use SharedPreferences, but saving the instance state is probably what you want here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号