PassengerTravelFrg fragment = new PassengerTravelFrg();
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
// if (first == 1) {
ft.replace(R.id.travel, fragment).commit();
//} else {
// ft.add(R.id.travel, fragment).commit();
// first = 1;
//}
R.id.travel is id of linear layout which must not have any fragment inside to
add or replace fragments dynamically.replace can also be used for first time
adding.
PassengerTravelFrg fragment =
.beginTransaction();
ft.add(R.id.travel, fragment).commit();
here R.id.travel is id of fragment declared in layout file to add fragment
only once initially.
FragmentTransaction ft = getFragmentManager()
.beginTransaction();
// if (first == 1) {
ft.replace(R.id.travel, fragment).commit();
//} else {
// ft.add(R.id.travel, fragment).commit();
// first = 1;
//}
R.id.travel is id of linear layout which must not have any fragment inside to
add or replace fragments dynamically.replace can also be used for first time
adding.
PassengerTravelFrg fragment =
getSupportFragmentManager().findFragmentById(R.id.travel);FragmentTransaction ft = getFragmentManager()
.beginTransaction();
ft.add(R.id.travel, fragment).commit();
here R.id.travel is id of fragment declared in layout file to add fragment
only once initially.
No comments:
Post a Comment