I want to call a method in the main operation to call a new fragment using ((FragmentActivity) Activity). ShowFragment (new SmokeSensor ());
however, it throws an error:
Unable to access non-static member of external type
'Android.Support.V4.App.Fragment' through a nested type
'*******. Fragments.Dashboard.ViewAdapter`
What am I doing wrong?
the code:
public void ShowFragment(SupportFragment fragment) { var transaction = SupportFragmentManager.BeginTransaction(); connectionStatus.Visibility = ViewStates.Gone; if (!ConnectionDetector.IsConnected(this)) { connectionStatus.Visibility = ViewStates.Visible; transaction.Detach(currentFragment); transaction.Commit(); drawerLayout.CloseDrawer(leftDrawer); return; } if (fragment == currentFragment) { transaction.Detach(currentFragment); transaction.Attach(currentFragment); transaction.Commit(); drawerLayout.CloseDrawer(leftDrawer); return; } transaction.SetCustomAnimations(Resource.Animation.slide_in, Resource.Animation.slide_out); transaction.Replace(Resource.Id.fragment_container, fragment); transaction.Commit(); drawerLayout.CloseDrawer(leftDrawer); currentFragment = fragment; }
source share