【发布时间】:2014-12-04 15:12:07
【问题描述】:
我正在检查片段生命周期,我在每个回调“onAttache,onViewCreated,...等”中放置了一个textView,但问题是fragment 布局定义在onCreateView() 和后面的后续回调而不是onAttch。我的问题是如何在onAttach() 回调中显示text 语句或示例“@onAttach()”?
【问题讨论】:
-
生命周期的进展很棒,但为什么要重新发明呢?片段应该独立于活动运行,因此不要太担心 onAttach() 方法。与活动 onResume() 相同,全局标志(布尔值)如果你没有显示你的文本(假)如果你显示了文本,则显示文本(真)然后不要更新它。
标签: android android-fragments textview fragment android-fragmentactivity