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;
}
------ Solution ----------------------------------- ---------
they seem Fragment of different classes.
onClick method you should put getFragmentManager.beginTransaction () removed.
It is my understanding that you want to convert Fragment, you should always get a new transaction.
as well as in your program each button creates a DetailFragment, so Fragment same every time.
------ Solution ---------------------------------------- ----
they seem Fragment of different classes.
onClick method you should put getFragmentManager.beginTransaction () removed.
It is my understanding that you want to convert Fragment, you should always get a new transaction.
as well as in your program each button creates a DetailFragment, so Fragment same every time.
------ reference ------------------------------------ ---
------ reference - --------------------------------------
created two different fragment, a DetailFragment, DetailtFragment
------ reference ---------------------------------- -----
When asked how the onclick method to remove getFragmentManager.beginTransaction () removed.
------ reference --------------------------------------- < br> changing for the better, thank you two
------ reference ------------------------------- --------
two different accounts, to restore the contents of exactly the same?
------ reference - --------------------------------------
transation.replace (R.id.fragment_container , detailt);
The id is the container's ID, not the debris itself ID. You may need to replace the fragment you write out the layout, adding an ID, this ID will pass your replace method.
------ reference --------------------------------------- < br> encountered similar problems, how to deal with it?
没有评论:
发表评论