Fragment declared target fragment that does not belong to this FragmentManager

前端 未结 3 2115
温柔的废话
温柔的废话 2020-12-29 08:17

I have made an activity A which has a fragment X in it. In fragment X, EditText item has on click event which opens fragment Y. This fragment displays a list of names. I pre

3条回答
  •  攒了一身酷
    2020-12-29 08:19

    To use setTargetFragment(), both the new Fragment and the target Fragment must be hosted within the same FragmentManager. The most common case where this would not happen is if you are using Activity.getSupportFragmentManager() or Fragment.getFragmentManager() alongside Fragment.getChildFragmentManager().

提交回复
热议问题