更新时间:2023-01-13 17:02:01
你可以通过标签找到你的片段,但是当然你需要在添加片段时,给它添加标签。
You can find your fragment by the Tag, but of course you need to give this tag to it while adding the fragment.
首先添加一个标签片段:
First add your fragment with a tag:
fragmentManager = getFragmentManager();
fragmentTransaction = fragmentManager.beginTransaction();
SomeFragment fragment = new ManageLinksFragment();
fragmentTransaction.add(R.id.fragment_container1,fragment, "sometag");
fragmentTransaction.commit();
然后在活动网站上:
SomeFragment mSomeFragment = (SomeFragment) getFragmentManager().findFragmentByTag("sometag");
// now mSomeFragment.callsomething();