Android examples for User Interface:Fragment
Find fragment by id
import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; public class Main { @SuppressWarnings("unchecked") public static <T extends Fragment> T findFragment(FragmentManager fm, Integer id) {//from w w w. j av a 2 s. co m if (fm == null) { return null; } return (T) fm.findFragmentById(id); } /** * * <b>BuildTime:</b> 2014-8-30<br> * <b>Description:</b> Find fragment by tag<br> * * @param fm * @param tag * @return */ @SuppressWarnings("unchecked") public static <T extends Fragment> T findFragment(FragmentManager fm, String tag) { if (fm == null) { return null; } return (T) fm.findFragmentByTag(tag); } }