开发者

How to check if Fragment was restored from a backstack?

Is that possible to check if Fragment was restored from a backstack? For example, if I had one, then replaced by 开发者_StackOverflow中文版another and back to previous by tapping "back" android button?


You need to have your own backstack and keep track of it.

Look at this: http://adblogcat.com/fragment-transition-animations-while-hiding-the-previous-fragment/

The code holds its own stack of fragments and hides them instead of removing them, giving it the same effect as replace (with backstack) except it doesn't recreate the fragment every time so the state of the fragment is always intact.

However, this code has a memory leak and I have to update it with the latest where the fragments don't persist. Hope this helps.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜