Android examples for User Interface:Fragment
Loads a fragment in a container and adds it to the backstack
/**/*from w ww .j a v a2s.c o m*/ * thesocialcoin * <p/> * Created by Lluis Ruscalleda Abad on 14/07/15. * Copyright (c) 2015 Identitat SL. All rights reserved. */ //package com.java2s; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentTransaction; public class Main { /** * Loads a fragment in a container and adds it to the backstack * * @param fragment : El fragment que se quiere colocar * @param containerID : El id del contenedor donde se va a colocar el fragment * @param activity : La actividad actual */ public static void loadFragmentAndAddToBackStack(Fragment fragment, int containerID, FragmentActivity activity) { FragmentTransaction transaction = activity .getSupportFragmentManager().beginTransaction(); transaction.replace(containerID, fragment); transaction.addToBackStack(null); transaction.setTransition(FragmentTransaction.TRANSIT_NONE); transaction.commit(); } }