MvvmCross / MvvmCross-AndroidSupport

Android support library packages for MvvmCross: The .NET MVVM framework for cross-platform solutions.
http://mvvmcross.com
15 stars 0 forks source link

Implemented MvxItemTemplateSelector - Item template selector from xml tag. #200

Closed thefex closed 8 years ago

thefex commented 8 years ago

I have implemented MvxItemTemplateSelector attribute. To use new functionallity:

  1. Create class which implements IItemTemplateSelector. Implementation should return view layout id - according to provided item.
  2. Add string in strings.xml like (value is "namespace.class, AssemblyName"): <string name="recyclerview_multiitem_templateselector">Example.Droid.Common.TemplateSelectors.MultiItemTemplateModelTemplateSelector, Example.Droid</string>
  3. Add your MvxRecyclerView with proper attribute like:
   <MvxRecyclerView
        android:id="@+id/my_recycler_view"
        android:scrollbars="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        local:MvxItemTemplateSelector="@string/recyclerview_multiitem_templateselector"
        local:MvxBind="ItemsSource Items; ItemClick ItemSelected" />

More info could be found in this issue: https://github.com/MvvmCross/MvvmCross-AndroidSupport/issues/196 and in Sample project.

Besides implementation of MultiItemTemplateSelector I have fixed Sample project ViewPager layouts (visual UI glitch).

sescandell commented 8 years ago

:+1: Like it!

martijn00 commented 8 years ago

Thanks! I'll merge this for now, and you can open another PR for the suggestions @vvolkgang has.

Cheesebaron commented 8 years ago

ItemTemplateId for IMvxRecylerAdapter is used in Leanback, so this PR does not build.