该错误,是因为你的ft事务是全局的变量,只能commit一次。
所以用两个局部ft事务去做commit即可。
//当点击对应的categoryTitle时 ft = fm.beginTransaction();//注意!!!!!!!!!!!!! switch (position) { case 0: ft.replace(R.id.content, new FeelingForecastBodyFragment()); break; case 1: ft.replace(R.id.content, new SocialBodyFragment()); break; case 2: ft.replace(R.id.content, new MapBodyFragment()); break; case 3: ft.replace(R.id.content, new AboutBodyFragment()); break; case 4: ft.replace(R.id.content, new OtherBodyFragment()); break; } ft.commit();