不能通过嵌套类型X访问外部类型X的非静态成员
本文关键字:类型 静态成员 外部 访问 嵌套类型 不能 | 更新日期: 2023-09-27 18:08:19
我想在Main Activity中调用一个方法来使用
调用一个新的Fragment((FragmentActivity)活动)。ShowFragment(新SmokeSensor ());
抛出错误:
不能访问外部类型
的非静态成员Android.Support.V4.App。
'*******. Fragments.Dashboard.ViewAdapter '
我做错了什么?
代码: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;
}
为什么你是"Android.Support.V4.App " ?"Fragment"在*******. fragments . dashboard中只能是静态的。ViewAdapter ?
见cannot- accessa -non-static- memberof -outer-type或者这个