簡體   English   中英

Xamarin.Android-具有分組標題的自定義RecyclerView

[英]Xamarin.Android - Custom RecyclerView with grouping header

我想創建一個自定義的recyclerView來進行分組。

我將Xamarin.Android與MVVMCross一起使用,我看到了這個存儲庫以創建帶有分組的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:在路徑:DexPathList [[zip file //]上找不到類“ android.view.MvxRecyclerView”數據/app/com.companyname.AndroidApp-1/base.a…}

{Java.Lang.ClassNotFoundException:在路徑:DexPathList [[zip file // data / app / com.companyname.AndroidApp-1 / base.apk“],nativeLibraryDirectories = [上找不到類“ android.view.MvxRecyclerView” /data/app/com.companyname.AndroidApp-1/lib/arm64、/data/app/com.compa…}

謝謝你的幫助

編輯 :現在我有此錯誤(我已經更新了我的axml代碼):

{System.NullReferenceException:對象引用未設置為對象的實例。 在C:\\ projects \\ mvvmcross \\ MvvmCross \\ Platform \\ Platform \\ Mvx.cs:33中的MvvmCross.Platform.Mvx.Resolve [TService]()[0x00006]在MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current [T] ()在C:\\ projects \\ mvvmcross \\ MvvmCross \\ Binding \\ Droid \\ BindingContext \\ MvxAndroidBindingContextHelpers.cs:[0x00000]在MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current:23(C:\\ projects \\ mvvmcross中的[0x00000] \\ MvvmCross \\ Binding \\ Droid \\ BindingContext \\ MvxAndroidBindingContextHelpers.cs:17(位於/Apps/Projects/AndroidApp/AndroidApp/AndroidApp/Controls/MvxRecyclerAdapter.cs:34中的/Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerAdapter.cs:34) MvxRecyclerView..ctor(Android.Content.Context上下文,Android.Util.IAttributeSet屬性)[0x00000]在/Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerView.cs:16中(包裝動態方法)System.Object: 1d68a509-a758-45e2-be4d-f4a51a401ff5(intptr,對象[])
在Java.Interop.TypeManager.n_Activate(System.IntPtr jnienv,System.IntPtr jclass,System.IntPtr typename_ptr,System.IntPtr signature_ptr,System.IntPtr jobject,System.IntPtr parameters_ptr)[0x000de] in:0}

它說Didn't find class "android.view.MvxRecyclerView" ,但是實際位置是不同的。 您可以添加您的命名空間或MvvmCross一個在該AndroidViewAssemblies Setup.cs

您應該添加如下內容:

protected override IEnumerable<Assembly> AndroidViewAssemblies => new 
List<Assembly>(base.AndroidViewAssemblies)
{
    typeof(MvxRecyclerView).Assembly
};

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM