2015年2月19日 星期四

ChildFragmentManager中找

Note: Each fragment requires a unique identifier that the system can use to restore the fragment if the activity is restarted (and which you can use to capture the fragment to perform transactions, such as remove it). There are three ways to provide an ID for a fragment:
  • Supply the android:id attribute with a unique ID.
  • Supply the android:tag attribute with a unique string.
  • If you provide neither of the previous two, the system uses the ID of the container view.

NewsListFragment fragmet = (NewsListFragment) getChildFragmentManager().findFragmentById( R.id.centerFrameLayout);

沒有留言:

張貼留言