(written at 2014-03-05 23:40:49)
该错误,是因为你的ft事务是全局的变量,只能commit一次。
所以用两个局部ft事务去做commit即可。
原文地址:http://blog.csdn.net/knxw0001/article/details/9363411
arjinmc补充:
FragmentManager fragmentManager = getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
detailFragment = new ProductDetailFragment(productId);
commentFragment = new ProductCommentFragment(productId);
fragmentTransaction.add(R.id.viewgroup, detailFragment);
fragmentTransaction.add(R.id.viewgroup, commentFragment);
fragmentTransaction.commit();
//下面这个是调用的时候需要用新的局部变量
getSupportFragmentManager().beginTransaction().hide(commentFragment).show(detailFragment).commit();