从我打开 VideoPlayerFragment 的主片段开始,在 VideoPlayerFragment 中,当我按下按钮时,它应该返回到父片段。
CollectionDemoActivity{
class LaunchpadSectionFragment extends ListFragments{
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
String fragMainGroups = "mainGroups";
Fragment fragment1 = new VideoPlayerFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.id.contentFragment, fragment1, fragMainGroups );
transaction.addToBackStack(fragMainGroups);
transaction.commit();
}
}
}
外部类
VideoPlayerFragment.java
类 VideoPlayerFragment 扩展 ListFragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
String Groups = "Groups";
Fragment fragment1 = new CollectionDemoActivity.LaunchpadSectionFragment();
FragmentTransaction transaction = getChildFragmentManager().beginTransaction();
transaction.replace(R.layout.load_main_groups_activty, fragment1, Groups);
transaction.addToBackStack(Groups);
transaction.commit();
}
}