我一直试图将页脚视图添加到MvxExpandableListView的每个组列表中,但未成功。
AddFooterView方法只是添加到整个列表的底部。
我一直在尝试创建一个继承自MvxExpandableListAdapter的自定义适配器,以便我可以尝试自己添加它。 但是,我得到" Android.Content.Res.Resources + NotFoundException:资源ID#0x0"当列表加载时,堆栈跟踪看起来好像是使用原始的MvxExpandableListAdapter而不是我创建的新的。
我的活动OnCreate
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.WorkOrderListing);
SetupToolbar();
SetupNavigationMenu(Resource.Id.nav_work_orders);
_listView = FindViewById<MvxExpandableListView>(Resource.Id.listing_workorders);
var adapter = new LoadMoreExpandableListAdapter(this, BindingContext as IMvxAndroidBindingContext);
_listView.SetAdapter(adapter);
}
我的布局文件中的列表视图
<Mvx.MvxExpandableListView
android:id="@+id/listing_workorders"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:dividerHeight="@dimen/expandablelist_divider_height"
android:childDivider="@color/line_grey"
android:contentDescription="WorkOrderListing_ExpandableList"
android:groupIndicator="@null"
local:MvxGroupItemTemplate="@layout/workorderlisting_header"
local:MvxItemTemplate="@layout/workorderlisting_detail"
local:MvxBind="ItemsSource WorkOrderLists; GroupClick GroupClickCommand; ItemClick ItemClickCommand" />
我的适配器,(在尝试添加页脚之前,只是尝试使用最少的代码才能使其正常工作)
public class LoadMoreExpandableListAdapter : MvxExpandableListAdapter
{
#region Constructors
public LoadMoreExpandableListAdapter(Context context) : base(context)
{
}
public LoadMoreExpandableListAdapter(Context context, IMvxAndroidBindingContext bindingContext) : base(context, bindingContext)
{
}
protected LoadMoreExpandableListAdapter(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer)
{
}
#endregion
public new View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent)
{
object rawItem = this.GetRawItem(groupPosition, childPosition);
return this.GetBindableView(convertView, rawItem, this.ItemTemplateId);
}
public new View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent)
{
object rawGroup = this.GetRawGroup(groupPosition);
return this.GetBindableView(convertView, rawGroup, this.GroupTemplateId);
}
}
我认为问题出现在MvxExpandableListView
的代码块中protected MvxExpandableListAdapter ThisAdapter {
get {
return this.ExpandableListAdapter as MvxExpandableListAdapter;
}
}
堆栈跟踪
Android.Content.Res.Resources+NotFoundException: Resource ID #0x0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Users/builder/data/lanes/3819/c1d1c79c/source/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:143
at Java.Interop.JniEnvironment+InstanceMethods.CallNonvirtualObjectMethod (Java.Interop.JniObjectReference instance, Java.Interop.JniObjectReference type, Java.Interop.JniMethodInfo method, Java.Interop.JniArgumentValue* args) [0x000a8] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniEnvironment.g.cs:11687
at Java.Interop.JniPeerMembers+JniInstanceMethods.InvokeVirtualObjectMethod (System.String encodedMember, Java.Interop.IJavaPeerable self, Java.Interop.JniArgumentValue* parameters) [0x0006b] in /Users/builder/data/lanes/3819/c1d1c79c/source/Java.Interop/src/Java.Interop/Java.Interop/JniPeerMembers.JniInstanceMethods_Invoke.cs:355
at Android.Views.LayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x00054] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Views.LayoutInflater.cs:653
at MvvmCross.Binding.Droid.Views.MvxLayoutInflater.Inflate (System.Int32 resource, Android.Views.ViewGroup root, System.Boolean attachToRoot) [0x0003e] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.CommonInflate (System.Int32 resourceId, Android.Views.ViewGroup viewGroup, System.Boolean attachToRoot) [0x00012] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContext.BindingInflate (System.Int32 resourceId, Android.Views.ViewGroup viewGroup, System.Boolean attachToRoot) [0x00000] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.Views.MvxAdapter.CreateSimpleView (System.Object dataContext) [0x00006] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.Views.MvxAdapter.GetSimpleView (Android.Views.View convertView, System.Object dataContext) [0x00003] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.Views.MvxAdapter.GetBindableView (Android.Views.View convertView, System.Object dataContext, System.Int32 templateId) [0x00003] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at MvvmCross.Binding.Droid.Views.MvxExpandableListAdapter.GetGroupView (System.Int32 groupPosition, System.Boolean isExpanded, Android.Views.View convertView, Android.Views.ViewGroup parent) [0x00011] in <0bd205dc7a7f4d20ae563bf31b6b4c87>:0
at Android.Widget.IExpandableListAdapterInvoker.n_GetGroupView_IZLandroid_view_View_Landroid_view_ViewGroup_ (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 groupPosition, System.Boolean isExpanded, System.IntPtr native_convertView, System.IntPtr native_parent) [0x0001b] in /Users/builder/data/lanes/3819/c1d1c79c/source/monodroid/src/Mono.Android/platforms/android-24/src/generated/Android.Widget.IExpandableListAdapter.cs:472
at at (wrapper dynamic-method) System.Object:3046abf5-3522-4b43-8977-6eb130a28c37 (intptr,intptr,int,bool,intptr,intptr)
at android.content.res.Resources$NotFoundException: Resource ID #0x0
at at android.content.res.Resources.getValue(Resources.java:1123)
at at android.content.res.Resources.loadXmlResourceParser(Resources.java:2309)
at at android.content.res.Resources.getLayout(Resources.java:939)
at at android.view.LayoutInflater.inflate(LayoutInflater.java:395)
at at md5bf0126c95bf9fc0db24c02c9adb4cfa7.MvxExpandableListAdapter.n_getGroupView(Native Method)
at at md5bf0126c95bf9fc0db24c02c9adb4cfa7.MvxExpandableListAdapter.getGroupView(MvxExpandableListAdapter.java:150)
at at android.widget.ExpandableListConnector.getView(ExpandableListConnector.java:446)
at at android.widget.AbsListView.obtainView(AbsListView.java:2263)
at at android.widget.ListView.makeAndAddView(ListView.java:1790)
at at android.widget.ListView.fillDown(ListView.java:691)
at at android.widget.ListView.fillFromTop(ListView.java:752)
at at android.widget.ListView.layoutChildren(ListView.java:1616)
at at android.widget.AbsListView.onLayout(AbsListView.java:2091)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.support.design.widget.CoordinatorLayout.layoutChild(CoordinatorLayout.java:1091)
at at android.support.design.widget.CoordinatorLayout.onLayoutChild(CoordinatorLayout.java:801)
at at android.support.design.widget.CoordinatorLayout.onLayout(CoordinatorLayout.java:815)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.RelativeLayout.onLayout(RelativeLayout.java:1055)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.support.v4.widget.DrawerLayout.onLayout(DrawerLayout.java:1187)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1671)
at at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1525)
at at android.widget.LinearLayout.onLayout(LinearLayout.java:1434)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.widget.FrameLayout.layoutChildren(FrameLayout.java:453)
at at android.widget.FrameLayout.onLayout(FrameLayout.java:388)
at at android.view.View.layout(View.java:14817)
at at android.view.ViewGroup.layout(ViewGroup.java:4631)
at at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1987)
at at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1744)
at at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
at at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at at android.view.Choreographer.doFrame(Choreographer.java:544)
at at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at at android.os.Handler.handleCallback(Handler.java:733)
at at android.os.Handler.dispatchMessage(Handler.java:95)
at at android.os.Looper.loop(Looper.java:136)
at at android.app.ActivityThread.main(ActivityThread.java:5017)
at at java.lang.reflect.Method.invokeNative(Native Method)
at at java.lang.reflect.Method.invoke(Method.java:515)
at at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at at dalvik.system.NativeStart.main(Native Method)