findFragmentByTag() returns null after perform a FragmentTransaction using replace() method

前端 未结 8 1704
广开言路
广开言路 2020-11-30 04:44

My Android app consists three fragments: A, B and C. They\'re loaded in the two containers defined in the MainActivity layout.

When th

8条回答
  •  隐瞒了意图╮
    2020-11-30 05:05

    I've fixed it! I called getSupportFragmentManager().executePendingTransactions() after doing the transaction and it worked! After calling that method I can get the fragment using both findFragmentById() and findFragmentByTag() methods.

提交回复
热议问题