为什么调用 onCreateView 方法后,字段中的所有内容仍然存在?
在 A
片段中,有字段和一个按钮,可将用户带到 B
片段,假设用户将数据插入字段内,然后单击按钮,现在用户在 B
片段中,假设用户决定回到 A
片段,A 中的
片段将被再次调用并重新创建所有视图但用户插入字段的所有数据仍然存在。onCreateView
方法
我知道 onCreateView 方法将销毁所有视图并再次重新创建它们。
这对我来说不是问题,而是一个功能,因为我想将所有数据保留在字段中。
仅出于知识目的,我想知道为什么即使调用 onCreateView
方法后字段内的所有内容仍然存在?
In the A
fragment there are fields and a button that will take the user to the B
fragment, Let's suppose the user inserts the data inside fields and after that clicked on the button, Now the user in the B
fragment, Let's suppose the user decided back to the A
fragment, The onCreateView
method in the A
fragment will be called again and will recreate all views but all data that user inserted it in fields still exist.
I know the onCreateView
method will destroy all views and recreate them again.
This is not a problem for me but rather it is a feature because I want to keep all data in the fields.
For the sake of knowledge only I want to know why all content inside fields still exists even after the onCreateView
method is called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每当重新创建片段时,都会保存/恢复视图状态
Views state is saved/restored whenever fragment is recreated