【发布时间】:2017-08-28 10:07:03
【问题描述】:
我想创建一个自定义 recyclerView 以具有分组部分。
我将 Xamarin.Android 与 MVVMCross 一起使用,我看到 this repo 制作了一个带有 Grouping 的 RecyclerView。
好吧,我复制了他所有的文件,并尝试编译我的解决方案(因为我必须使用 MVVMCross v5.0.5):
我做了这个简单的页面:
<?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="match_parent"
android:layout_height="match_parent">
<androidapp.controls.MvxRecyclerView
android:id="@+id/my_recycler_view"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
local:MvxItemTemplate="@layout/listitem_recyclerviewexample"
MvxHeaderLayoutId="@layout/recyclerviewexample_header"
MvxFooterLayoutId="@layout/recyclerviewexample_footer"
MvxHidesHeaderIfEmpty="true"
MvxHidesFooterIfEmpty="true"
local:MvxBind="ItemsSource Items; ItemClick ItemSelected"/>
</LinearLayout>
但是显示我的页面时出现此错误:
{Android.Views.InflateException:二进制 XML 文件第 1 行:错误 膨胀类 MvxRecyclerView ---> Java.Lang.ClassNotFoundException: 在路径上找不到类“android.view.MvxRecyclerView”: DexPathList[[zip 文件“/data/app/com.companyname.AndroidApp-1/base.a…}
和
{Java.Lang.ClassNotFoundException: 找不到类 路径上的“android.view.MvxRecyclerView”:DexPathList[[zip 文件 "/data/app/com.companyname.AndroidApp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.AndroidApp-1/lib/arm64, /data/app/com.compa…}
感谢您的帮助
编辑:现在我有这个错误(我已经更新了我的 axml 代码):
{System.NullReferenceException:对象引用未设置为 对象的实例。在 MvvmCross.Platform.Mvx.Resolve[TService] () [0x00006] 在 C:\projects\mvvmcross\MvvmCross\Platform\Platform\Mvx.cs:33 在 MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current[T] () [0x00000] 在 C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContextHelpers.cs:23 在 MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current () [0x00000] 在 C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContextHelpers.cs:17 在 AndroidApp.Controls.MvxRecyclerAdapter..ctor () [0x00000] 中 /Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerAdapter.cs:34 在 AndroidApp.Controls.MvxRecyclerView..ctor (Android.Content.Context 上下文,Android.Util.IAttributeSet attrs) [0x00000] 在 /Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerView.cs:16 在(包装动态方法) System.Object:1d68a509-a758-45e2-be4d-f4a51a401ff5 (intptr,object[])
在 Java.Interop.TypeManager.n_Activate (System.IntPtr jnienv, System.IntPtr jclass,System.IntPtr typename_ptr,System.IntPtr signature_ptr,System.IntPtr 作业,System.IntPtr 参数_ptr) [0x000de] 在 :0 }
【问题讨论】:
-
从未收到此错误,但发现类似this one。
标签: c# android-recyclerview xamarin.android mvvmcross