customFragment到customFragment

时间:2016-04-01 11:15:36

标签: android android-fragments

我想在点击另一个CustomFragment(ChatListFragment)内的按钮时显示ProfileFragment(CustomFragment),Code I' m using using给我错误;

Fragment f = null;
f=(Fragment)new Profile();
            getActivity().getFragmentManager().beginTransaction().replace(R.id.content_frame, f.getFragmentManager()).commit();

错误我得到的是不兼容的类型

Required : com.android.Fragment
Found: com.myapp.ui.Profile

1 个答案:

答案 0 :(得分:0)

试试这个:

Fragment f = new Profile();
getActivity().getFragmentManager().beginTransaction().replace(R.id.content_frame, f).commit();