0

I have one Activity with five fragments. By default the first fragment is displayed when the user clicks on Submit, then the second fragment is displayed. However I don't understand how to get back to the previous fragment.

Michael Dodd
  • 10,102
  • 12
  • 51
  • 64
Ext1 Dev
  • 33
  • 2
  • 6

1 Answers1

0

try this,

add this code in your activity.

Fragment fragment = null;

switch (menu.get(position).name) {

            case "Board": {

                progressBar.setVisibility(View.VISIBLE);
                fragment = new TabHostFragment(); // your fragment
                break;
            }
            case "Test": {

                fragment = new ScheduledTestsFragment(); // your fragment
                break;
            }
 if (fragment != null) {

            getSupportFragmentManager().beginTransaction()
                    .replace(R.id.content_frame, fragment)
                    .commit();
        }
Gayathri
  • 249
  • 3
  • 13