我在 Mono for Android 中使用 MvvmCross 的活动时遇到问题。基本上,应用程序编译并运行,但是当我调用 SetContentView 时出现未处理的异常:
“Android.Views.InflateException:二进制 XML 文件第 1 行:膨胀类 Mvx.MvxBindableListView 时出错”
在堆栈跟踪中,它提到未找到的类是原因。
这是我的活动:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Cirrious.MvvmCross.Droid.Views;
using WshLst.Core.ViewModels;
using WshLst.Core.Models;
namespace WshLst.MonoForAndroid.Views
{
[Activity(Label = "Wsh Lst - Login")]
public class LoginView : MvxActivityView<LoginViewModel>
{
ListView list;
protected override void OnViewModelSet()
{
RequestWindowFeature(WindowFeatures.ActionBar);
SetContentView(Resource.Layout.Page_LoginView);
list = this.FindViewById<ListView>(Resource.Id.mvxList);
list.ItemClick += (s, e) =>
{
var item = list.Adapter.GetItem(e.Position);
var castItem = (Cirrious.MvvmCross.Binding.Droid.MvxJavaContainer)item;
this.ViewModel.Login((WshLst.Core.Models.LoginPlatform)castItem.Object);
};
}
}
}