I want to call a method in the Main Activity to call a new Fragment using
((FragmentActivity)Activity).ShowFragment(new SmokeSensor());
however it throws the error:
Cannot access a non-static member of outer type
'Android.Support.V4.App.Fragment' via nested type
'*******.Fragments.Dashboard.ViewAdapter`
What am I doing wrong?
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;
}
((FragmentActivity)Activity).ShowFragment(new SmokeSensor());
is not static.RecyclerView.ViewHolder OnCreateViewHolder
which appearantely doesn't like it