我有这个代码:
using Android.App;
using Android.Content;
using Android.OS;
using MvvmCross;
using MvvmCross.Droid.Support.V7.AppCompat;
using MvvmCross.Forms.Views;
using MvvmCross.ViewModels;
using System;
using Xamarin.Forms.Platform.Android;
[....]
private void SetupPage()
{
if (_pageType == null) throw new NullReferenceException("ContentPage type can't be null. Call SetTypes() before creating the Intent");
if (_viewModelType == null) throw new NullReferenceException("ViewModel type can't be null. Call SetTypes() before creating the Intent");
var viewModel = Mvx.IoCProvider.Resolve(_viewModelType) as IMvxViewModel;
var page = Activator.CreateInstance(_pageType) as MvxContentPage ??
Mvx.IoCProvider.Resolve(_pageType) as MvxContentPage;
if(page == null || viewModel == null)
return;
page.ViewModel = viewModel;
var fragment = page.CreateSupportFragment(this);
SupportFragmentManager
.BeginTransaction()
.Replace(Resource.Id.fragment_container, fragment)
.Commit();
}
字符串
我尝试使用Android.Support.V4.App.Fragment fragment更新var fragment,但在此行出现此错误:
- 无法将类型“AndroidX.Fragment.App.Fragment”隐式转换为“Android.Support.V4.App.Fragment”*
的数据
1条答案
按热度按时间lbsnaicq1#
请使用
AndroidX.Fragment.App.Fragment
而不是AndroidX.Fragment.V4.App.Fragment
。尝试替换以下代码:
字符串
使用:
型