开发者

How to retain the state of inflated layout in android

开发者 https://www.devze.com 2023-04-10 17:16 出处:网络
Can anybody tell me how to retain the state of inflated开发者_高级运维 layout while configuration changes, in android?

Can anybody tell me how to retain the state of inflated开发者_高级运维 layout while configuration changes, in android? Can anybody provide some sample code?

Thanks


It's not cleat which part you have problem with. But anyway, take a good read of:

  1. Activity Lifecycle: Saving Activity state
  2. Handling Runtime [Configuration] Changes

Also, all views with assigned id's usually save their state themself.


Activity.onSaveInstanceState - save current state

Activity.onRestoreInstanceState - restore from saved state

More reading: http://developer.android.com/reference/android/app/Activity.html#SavingPersistentState


This is one trick I've learned to retain the current layout when configuration changes: http://xjaphx.wordpress.com/2011/09/19/the-less-known-over-screen-orientation/

0

精彩评论

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

关注公众号