0
votes

I want to create a custom recyclerView to have grouping section.

I use Xamarin.Android with MVVMCross, and I saw this repo to make a RecyclerView with Grouping.

Well, I copy all his files, and tried to compile my solution (because I must to use MVVMCross v5.0.5):

My project

I made this simple page:

<?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>

But I have this error when my page is displayed:

{Android.Views.InflateException: Binary XML file line #1: Error inflating class MvxRecyclerView ---> Java.Lang.ClassNotFoundException: Didn't find class "android.view.MvxRecyclerView" on path: DexPathList[[zip file "/data/app/com.companyname.AndroidApp-1/base.a…}

And

{Java.Lang.ClassNotFoundException: Didn't find class "android.view.MvxRecyclerView" on path: DexPathList[[zip file "/data/app/com.companyname.AndroidApp-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.AndroidApp-1/lib/arm64, /data/app/com.compa…}

Thanks for your help

EDIT : Now I have this error (I have updated my axml code):

{System.NullReferenceException: Object reference not set to an instance of an object. at MvvmCross.Platform.Mvx.Resolve[TService] () [0x00006] in C:\projects\mvvmcross\MvvmCross\Platform\Platform\Mvx.cs:33 at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current[T] () [0x00000] in C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContextHelpers.cs:23 at MvvmCross.Binding.Droid.BindingContext.MvxAndroidBindingContextHelpers.Current () [0x00000] in C:\projects\mvvmcross\MvvmCross\Binding\Droid\BindingContext\MvxAndroidBindingContextHelpers.cs:17 at AndroidApp.Controls.MvxRecyclerAdapter..ctor () [0x00000] in /Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerAdapter.cs:34 at AndroidApp.Controls.MvxRecyclerView..ctor (Android.Content.Context context, Android.Util.IAttributeSet attrs) [0x00000] in /Users/Projects/AndroidApp/AndroidApp/Controls/MvxRecyclerView.cs:16 at (wrapper dynamic-method) System.Object:1d68a509-a758-45e2-be4d-f4a51a401ff5 (intptr,object[])
at 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 }

1
Never got this error but found something like this one.Ashish Srivastava

1 Answers

3
votes

It says Didn't find class "android.view.MvxRecyclerView", but the real location is different. You can add your namespace or the MvvmCross one to the AndroidViewAssemblies in the Setup.cs.

You should add something like this:

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