In my example am having a view pager inside a fragment and tabs in View pager are crated dynamically. For example, am having tab for three subjects Sub 1
, Sub 2
, Sub 3
each subject tab having some number of questions. Now what i want is when i switch from one tab to another tab should be reloaded or refreshed.
I have google a lot what i found to refresh the fragment is
Fragment currentFragment = getFragmentManager().findFragmentByTag("FRAGMENT");
FragmentTransaction fragTransaction = getFragmentManager().beginTransaction();
fragTransaction.detach(currentFragment);
fragTransaction.attach(currentFragment);
fragTransaction.commit();
So is this is only way to refresh Tab fragment or any suggestions?