在我的应用程序中,我有多个片段,但我无法在片段之间切换。当我单击 button1 时,它会显示正确的片段。但是当我点击button2时,它没有显示相应的片段。
以下是我的相关代码:
fragmentM = getFragmentManager();
transation = fragmentM.beginTransaction();
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.search:
break;
case R.id.btnun:
detail = new DetailFragment();
transation.add(R.id.fragment_container, detail);
transation.addToBackStack(null);
transation.commit();
break;
case R.id.btnch:
detailt = new DetailtFragment();
transation.replace(R.id.fragment_container, detailt);
transation.addToBackStack(null);
transation.commit();
break;
}