片段onHiddenChanged不叫不叫、片段、onHiddenChanged

2023-09-07 15:52:25 作者:亡命

我最近添加片段我的应用程序。对于新的应用程序,我需要得到一旦示出我的片段通知。所以,我可以马上做一些计算作为我的片段再次显示。

我的片段使用具有TabIndicator和它的其中仅使用一个FragmentClass几次。

下面是正常标准覆盖类:

  @覆盖公共无效onHiddenChanged(布尔隐藏){    super.onHiddenChanged(隐藏);} 

解决方案

仍在寻找答案? onHiddenChanged不会被调用的第一次显示一个片段。只有当它改变状态。

从文档:

  

片段时,隐藏的状态(如是否隐藏()返回)已经改变调用。片段开始时没有隐藏;这将被称为每当片段从改变状态。

漫威 钢铁侠的灵魂可能就在灵魂宝石之中

I recently added Fragments to my applications. For a new application i'll need to get notified as soon as my fragment is shown. So i can do some calculations as soon as my fragment is shown again.

My Fragment is used with a TabIndicator and it's only one FragmentClass which is used a few times.

Here's the normal standard override class:

@Override
public void onHiddenChanged(boolean hidden) {
    super.onHiddenChanged(hidden);
}

解决方案

Still looking for an answer? onHiddenChanged doesn't get called the first time an fragment is shown. Only when it changes state.

From the documentation:

Called when the hidden state (as returned by isHidden()) of the fragment has changed. Fragments start out not hidden; this will be called whenever the fragment changes state from that.