且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

刷新其父活动的片段

更新时间: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();