开发者

Android Development: How To Keep Text When Orientation Changes?

开发者_运维问答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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜