fragmentManager为null?
MyFragment myFragment=new MyFragment(); FragmentManager fragmentManager = myFragment.getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.layout,myFragment); fragmentTransaction.commit();