我有一个自定义的BindableExpandableListView,它使用不同的ItemTemplates,具体取决于项目的类型。 当我现在有一个应该使用包含MvxBindableLinearLayout的布局的项目时,它会抛出一个
Android.Views.InflateException:正在加载...
指向MvxAdapter的GetBindableView方法的异常。
错误:
[0:]
MvxBind:Error: 35,20 View type not found - Mvx.MvxBindableLinearLayout
[0:] MvxBind:Error: 35,20 View type not found - Mvx.MvxBindableLinearLayout
03-28 11:25:37.508 I/mono-stdout( 4758): MvxBind:Error: 35,20 View type not found - Mvx.MvxBindableLinearLayout
An unhandled exception occured.
03-28 11:25:43.248 I/dalvikvm( 4758): threadid=3: reacting to signal 3
03-28 11:25:43.278 I/dalvikvm( 4758): Wrote stack traces to '/data/anr/traces.txt'
03-28 11:25:47.398 I/MonoDroid( 4758): UNHANDLED EXCEPTION: Android.Views.InflateException: Exception of type 'Android.Views.InflateException' was thrown.
03-28 11:25:47.398 I/MonoDroid( 4758): at Android.Runtime.JNIEnv.CallObjectMethod (intptr,intptr,Android.Runtime.JValue[]) [0x00064] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/src/Runtime/JNIEnv.g.cs:194
03-28 11:25:47.398 I/MonoDroid( 4758): at Android.Views.LayoutInflater.Inflate (int,Android.Views.ViewGroup,bool) [0x00043] in /Users/builder/data/lanes/monodroid-mlion-monodroid-4.12-series/a1e3982a/source/monodroid/src/Mono.Android/platforms/android-8/src/generated/Android.Views.LayoutInflater.cs:468
In mgmain JNI_OnLoad
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate (int,Android.Views.ViewGroup,Cirrious.MvvmCross.Binding.Droid.Binders.IMvxLayoutInfactorFactory,bool) <IL 0x00046, 0x00287>
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (int,Android.Views.ViewGroup,bool) <IL 0x00015, 0x00107>
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (int,Android.Views.ViewGroup) <IL 0x00004, 0x00063>
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.Views.MvxListItemView..ctor (Android.Content.Context,Cirrious.MvvmCross.Binding.Droid.Views.IMvxLayoutInflater,object,int) <IL 0x0001a, 0x000cf>
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.CreateBindableView (object,int) <IL 0x00013, 0x000bb>
Unhandled Exception:
Android.Views.InflateException: Loading...
03-28 11:25:47.398 I/MonoDroid( 4758): at Cirrious.MvvmCross.Binding.Droid.Views.MvxAdapter.GetBindableView (Android.Views.View,object,int) <IL 0x00027, 0x0027b>
The program 'Mono' has exited with code 0 (0x0).
我的布局:
包含章节的可扩展列表:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<BindableExpandableListView
android:descendantFocusability="blocksDescendants"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/EventList"
android:groupIndicator="@null"
android:dividerHeight="1px"
android:divider="#cccccc"
android:fadingEdgeLength="0px"
local:MvxBind="ItemsSource Sections; ItemClick ItemSelectedCommand; ItemLongClick ItemLongClickCommand"
local:GroupItemTemplate="@layout/eventlistitem_header" />
</LinearLayout>
有问题的项目的项目模板:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:id="@+id/txt_myEventTitle"
android:textSize="8pt"
android:textColor="#000000"
android:gravity="center_vertical"
android:layout_height="wrap_content"
android:paddingLeft="12dip"
android:paddingTop="12dip"
android:paddingBottom="12dip"
android:background="#ffffff"
local:MvxBind="Text Title" />
<Mvx.MvxBindableLinearLayout
android:layout_width="fill_parent"
android:orientation="vertical"
android:id="@+id/list_EventDetail_Ranking"
android:layout_height="wrap_content"
local:MvxBind="ItemsSource Ranking"
local:MvxItemTemplate="@layout/eventlistsubitem_rank" />
</LinearLayout>
BindableLinearLayout的项目模板:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="22dip">
<TextView
android:text="1."
android:layout_width="0dp"
android:layout_weight="0.1"
android:textSize="6.5pt"
android:textColor="#666666"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:paddingLeft="12dip"
android:background="#ffffff"
local:MvxBind="Text Rank" />
<TextView
android:text="Krasser Typ"
android:layout_width="0dp"
android:layout_weight="0.65"
android:textSize="6.5pt"
android:textColor="#666666"
android:gravity="center_vertical"
android:layout_height="match_parent"
android:background="#ffffff"
local:MvxBind="Text Player" />
<TextView
android:text="0"
android:layout_width="0dp"
android:layout_weight="0.25"
android:layout_height="fill_parent"
android:textSize="6.5pt"
android:textColor="#000000"
android:background="#ebebeb"
android:gravity="center_vertical"
android:paddingLeft="12dip"
android:textStyle="bold"
local:MvxBind="Text Mark" />
</LinearLayout>
</LinearLayout>
在BindableExpandableListViewAdapter中调用MvxAdapter的GetBindableView方法的方法:
public View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView,
ViewGroup parent)
{
var sublist = ((_itemsSource[groupPosition]) as SectionModel).Events.ToList();
var item = sublist[childPosition];
// Item Template depends on Datatype
if (item is EventListModel1)
ItemTemplateId = Resource.Layout.eventlistitem_event1;
else if (item is EventListModel2)
ItemTemplateId = Resource.Layout.eventlistitem_event2;
else if (item is EventListModel3)
ItemTemplateId = Resource.Layout.eventlistitem_event3;
else if (item is RankEventModel)
ItemTemplateId = Resource.Layout.eventlistitem_rank;
else
ItemTemplateId = Resource.Layout.eventlistitem_null;
return base.GetBindableView(convertView, item, ItemTemplateId);
}
基本上我需要的是一个包含以下内容的可扩展列表:
1级(动态包含章节)
- 级别2(动态包含针对不同事件的具有不同布局的事件)
---级别3(仅对特定EventType需要包含具有动态条目数量的排名表)
答案 0 :(得分:2)
错误是&#34;找不到查看类型 - Mvx.MvxBindableLinearLayout&#34;
这看起来像是在使用非常旧的代码? MvxBindableLinearLayout
是一个vNext类。在第3版中,我们简化了命名 - 因此使用了像MvxLinearLayout
这样的名称。