开发者

How to retain the state of inflated layout 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜