2

I have an activity in which layout has Tabs using TabLayout and viewpager from fragments. There are two tabs and having 2 fragments 1 for each tab. Now I am on second Tab's Fragment, when I perform any action in this fragment, I have to reload that fragment, but when I am restarting that activity using the below code:

((Activity)mContext).finish();
mContext.startActivity(((Activity) mContext).getIntent());

It reloads the first fragment, I want to reload the second fragment, how can I achieve this.

Thanks you so much for your help.

Prithniraj Nicyone
  • 5,021
  • 13
  • 52
  • 78

1 Answers1

0

Try to refresh your current Fragment:

// Reload current fragment

Fragment frg = null;
frg = getSupportFragmentManager().findFragmentByTag("Your_Fragment_TAG");
final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
ft.detach(frg);
ft.attach(frg);
ft.commit();
Suhas Bachewar
  • 1,230
  • 7
  • 21