Android examples for User Interface:Fragment
update Fragment
//package com.java2s; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import java.util.List; public class Main { public static void updateFragment(FragmentManager fragmentManager) { Fragment currentFragment = getVisibleFragment(fragmentManager); if (currentFragment == null) { return; }/*from ww w . j a v a 2 s.com*/ FragmentTransaction fragTransaction = fragmentManager .beginTransaction(); fragTransaction.detach(currentFragment); fragTransaction.attach(currentFragment); fragTransaction.commit(); } public static Fragment getVisibleFragment( FragmentManager fragmentManager) { List<Fragment> fragments = fragmentManager.getFragments(); for (Fragment fragment : fragments) { if (fragment != null && fragment.isVisible()) return fragment; } return null; } }