在TabLayout中为Fragment添加onStop以保存部分内容。

huangapple 未分类评论47阅读模式
英文:

onStop for Fragment in TabLayout to save some content

问题

我有一个带有两个选项卡或片段的TabLayout。

在一个片段中,我想在切换选项卡或关闭应用程序之前保存例如来自编辑文本的文本。

我尝试使用onStop。它在关闭应用程序之前保存内容。但当我切换到第二个选项卡时,应用程序会关闭而没有异常。

为什么?这个问题有解决办法吗?

英文:

I have a TabLayout with two Tabs or Fragments.

In one Fragment I want to save for example text from edittext before switching tab or closing app.

I tried with onStop. It save the content before closing app. But when I go to second tab, the app closes without exception.

Why? Are the a solution for this problem?

huangapple
  • 本文由 发表于 2020年5月29日 07:19:12
  • 转载请务必保留本文链接:https://java.coder-hub.com/62076110.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定