dimanche 24 mai 2015

2nd list to replace 1st list - which method?

For my tablet app there are 2 list views for the master fragment & the 1st list appear when I run my app. After tapping a list item in the first list, I want the second list to replace the first list within the master fragment but I'm not sure which method I need to use (replace or detach + attach). Also when viewing the 2nd list, if the user taps the back button I want the 2nd list of disappear and the 1st list to reappear. The code below replaces the master container but I'm not sure this the correct code for what I want to achieve. All relevant help would be appreciated.

FragmentAbout newFragment = new FragmentAbout();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();

transaction.replace(R.id.master_container, newFragment);
transaction.addToBackStack(null);
transaction.commit();

Aucun commentaire:

Enregistrer un commentaire