android layout - MvvmCross : dynamic item template selection for MvxListView -
if have view following mvxlistview definition:
<mvx.mvxlistview android:layout_margintop="10px" android:textfilterenabled="true" android:choicemode="singlechoice" android:layout_width="fill_parent" android:layout_height="fill_parent" android:textsize="20dp" local:mvxbind="itemssource data; itemclick launchcapabilityviewcmd" local:mvxitemtemplate="@layout/itemtemplate1" />
instead of hard coding mvxitemtemplate itemtemplate1, it possible dynamically set based on type of data want display in view? looking similar functionality wpf's datetemplateselector.
tia.
you have use custom adapter this.
a few of samples show how use cell type selection. see:
polymorphic lists in https://github.com/slodge/mvvmcross-tutorials/tree/master/working%20with%20collections
grouped lists in session list views in https://github.com/slodge/mvvmcross-tutorials/tree/master/sample%20-%20cirriousconference
e.g. polymorphiclistitemtypesview.cs
protected override view getbindableview(view convertview, object source, int templateid) { if (source kitten) templateid = resource.layout.listitem_kitten; else if (source dog) templateid = resource.layout.listitem_dog; return base.getbindableview(convertview, source, templateid); }
for android, there optimisation should added existing polymorphic adapter samples - include use of getitemviewtype
better convertview
reuse - see https://github.com/slodge/mvvmcross/issues/333
this questions linked to:
Comments
Post a Comment