gpt4 book ai didi

android - 无法在 xamarin MVVMCROSS 中从 android.support.v4.app.Fragment 转换为 android.app.Fragment

转载 作者:行者123 更新时间:2023-11-30 01:39:44 25 4
gpt4 key购买 nike

嘿,在 android(Xamarin) 中,我正在尝试在操作栏中添加选项卡,我已经完成了,但是当我使用切换按钮时,会显示此错误

“FragmentTransaction”是“Android.App.FragmentTransaction”和“Android.Support.V4.App.FragmentTransaction”之间的模糊引用

这是我的代码

protected override void OnCreate(Bundle bundle)
{

DrawerLayout mDrawerLayout;

base.OnCreate(bundle);

// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);

mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);

mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, Resource.Drawable.drawer, Resource.String.open_drawer, Resource.String.close_drawer);


FragmentTransaction transaction = FragmentManager.BeginTransaction();
SlidingTabsFragment fragment = new SlidingTabsFragment();
transaction.Replace(Resource.Id.sample_content_fragment, fragment);
transaction.Commit();

mDrawerLayout.SetDrawerListener(mDrawerToggle);
ActionBar.SetDisplayHomeAsUpEnabled(true);
ActionBar.SetHomeButtonEnabled(true);

}

最佳答案

使用 Android.App.FragmentTransaction transaction = FragmentManager.BeginTransaction();

关于android - 无法在 xamarin MVVMCROSS 中从 android.support.v4.app.Fragment 转换为 android.app.Fragment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34650871/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com