I am trying to call a method from FragmentStatePagerAdapter to add and removed tabs.
public class TabPagerAdapter extends FragmentStatePagerAdapter {
public void removeTab(int position) {
new MainActivity().tabLayout.removeTabAt(1);
notifyDataSetChanged();
}
}
Now in the main activity I want to call it so that i can remove the tab on ActivityResult
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//this gives error
new TabPagerAdapter().removeTab(1);
}
could you please help me with this ? Thank you.