简体   繁体   English

片段显示和活动生命周期

[英]Fragment showing and Activity lifecycle

I thought that when I call 我打电话的时候想到了

fragment.show(getSupportFragmentManager(), tag);

the activity were to PAUSED state by the calling of the onPause() method. 通过调用onPause()方法,活动处于PAUSED状态。 But debugging the project I discovered that no lifecycle method is called. 但是调试项目我发现没有调用生命周期方法。 I was planning the flow to use the onPause() and onResume() methods when I call and dismiss a fragment, but it is confusing me. 当我调用和解散一个片段时,我正计划使用onPause()和onResume()方法,但这让我很困惑。 Can someone help me please? 有人能帮助我吗?

Some observations regarding the show() method: 关于show()方法的一些观察:

  • It belongs to a DialogFragment ( link ); 它属于DialogFragment链接 );
  • It is only described by a fragment transaction (does not affect activity into enter onPause() state): 它仅由片段事务描述(不影响进入onPause()状态的活动):

    public void show(FragmentManager manager, String tag) { mDismissed = false; public void show(FragmentManager manager,String tag){mDismissed = false; mShownByMe = true; mShownByMe = true; FragmentTransaction ft = manager.beginTransaction(); FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.add(this,tag); ft.commit(); ft.commit(); } }

Detailed information about an Activity lifecycle: link1 and link2 有关Activity生命周期的详细信息: link1link2

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM