Android – how do I know the fragment ID of the fragment provided by the tabbed activity template

I have used the tabbed activity template provided by Android studio, but I can't find the IDs of different fragments used. The template has only one. XML and. Java for all three fragments. I made some changes and created three. XML and. Java for these three fragments respectively. But I can't figure out how to set IDs for different fragments in. XML or. Java. If there is no ID, I can't communicate between segments

resolvent:

Now used to retrieve clips

Fragment f = getSupportFragmentManager().findFragmentByTag(getFragmentTag(mViewPager.getId(), mViewPager.getCurrentItem()));


public static String getFragmentTag(int viewId, long id) {
    return "android:switcher:" + viewId + ":" + id;
}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>