I have a view that has a tablayout that activates a viewpager, when viewing the page it works fine, but if I click on an item on that view and then go back to the past screen I get:
Java.Lang.IllegalStateException: FragmentManager is already executing transactions
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
CurrentActivity = Activity;
var view = inflater.Inflate(Resource.Layout.fragment_directory, null);
_tabLayout = view.FindViewById<TabLayout>(Resource.Id.directory_tabs);
_viewPager = view.FindViewById<ViewPager>(Resource.Id.directory_pager);
SetTabLayout();
SetViewPager();
return view;
}
private void SetTabLayout()
{
var userTab = _tabLayout.NewTab();
userTab.SetText("Users");
var orgUnitsTab = _tabLayout.NewTab();
orgUnitsTab.SetText("Organizations");
_tabLayout.AddTab(userTab);
_tabLayout.AddTab(orgUnitsTab);
_tabLayout.TabGravity = TabLayout.GravityFill;
}
private void SetViewPager()
{
var pagerAdapter = new DirectoryPagerAdapter(FragmentManager, _tabLayout.TabCount);
_viewPager.Adapter = pagerAdapter;
_viewPager.AddOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(_tabLayout));
}
not sure if it makes a difference but when I leave this view I go from a fragment to an activity.