Android examples for User Interface:Fragment
get Current Fragment
//package com.java2s; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentManager; import java.util.List; public class Main { public static Fragment getCurrentFragment(FragmentActivity activity) { if (activity == null) return null; FragmentManager manager = activity.getSupportFragmentManager(); List<Fragment> fragmentList = manager.getFragments(); if (fragmentList != null) { for (int i = fragmentList.size() - 1; i > -1; i--) { Fragment aFragmentList = fragmentList.get(i); if (aFragmentList != null && aFragmentList.isVisible()) return aFragmentList; }/* www.ja v a 2 s .c om*/ } return null; } }