开发者

Views whose state spans multiple Activities

开发者 https://www.devze.com 2023-01-29 15:12 出处:网络
How can I create a custom view whose state spans multiple Activities?Creating a custom view is not the hard part.

How can I create a custom view whose state spans multiple Activities? Creating a custom view is not the hard part.

To be specific, I am using a sliding drawer, and I want this drawer to maintain开发者_运维百科 it's state as it appears on more than 1 activity. I haven't seen a coded example of doing this, hoping someone else has. Thanks.


Depends on just how long it should span it. You may want to consider storing its state in the SharedPreferences - that way, it will persist even if you reset the phone.

If it's "just quick", you could pass the state data in the intent extras.

You could also consider static variables, but keep in mind that your activity could be killed off as soon as the user moves to something else, so if the user comes back, you may have lost your state.

0

精彩评论

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