Unable to access non-static member of external type X via nested type X

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; } 
+4
source share
1 answer

why you "Android.Support.V4.App.Fragment" can only be static in *******. Fragments.Dashboard.ViewAdapter?

see cannot-access-a-non-static-member-of-outer-type or this

0
source

All Articles