Android - Set fragment id

前端 未结 7 1653
没有蜡笔的小新
没有蜡笔的小新 2020-11-27 15:22

How can I set a Fragment\'s Id so that I can use getSupportFragmentManager().findFragmentById(R.id.--)?

7条回答
  •  南方客
    南方客 (楼主)
    2020-11-27 15:55

    In most cases you can use the fragment tag as well as the ID.
    You can set the tag value in FragmentTransaction.add(Fragment fragment, String tag );. Then you can use the command FragmentManager.findFragmentByTag(String tab) to find the fragment in question.

提交回复
热议问题