ObservableAdapter with custom layout

Mar 27 at 8:48 AM
Edited Mar 27 at 10:55 AM
Hi,

I'm using Xamarin and MVVM Light for Android development and I observed a strange behavior when I tried to use the ObservableAdapter together with a custom listview item layout.

I used the layout quite a while before even using the ObservableAdapter and MVVM Light and it worked fine. It is basically a two line layout where both lines are given a textSize in scale pixels which is a modified version of the layout found here:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="?android:attr/listPreferredItemHeight"
    android:padding="6dip" >

    <TextView
        android:id="@+id/secondLine"
        android:layout_width="fill_parent"
        android:layout_height="26dip"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:ellipsize="marquee"
        android:singleLine="true"
        android:text="Description"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/firstLine"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/secondLine"
        android:layout_alignParentRight="true"
        android:layout_alignParentTop="true"
        android:layout_alignWithParentIfMissing="true"
        android:gravity="center_vertical"
        android:text="Example application"
        android:textSize="16sp" />

</RelativeLayout> 
Before using the ObservableAdapter I implemented a custom adapter and used the following line for layout inflation:
inflater.Inflate(Resource.Layout.ListViewInteractionRow, parent, false);
Since the delegate of the ObservableAdapter does not take the parent parameter I followed this article and converted the line to:
inflater.Inflate(Resource.Layout.ListViewInteractionRow, null);
This line is part of the callback passed to the GetAdapter function and is located in the activity showing the list. So when I do this, the layout is not correctly inflated and only one line of text is shown for every list item. However, when I change use the build-in layout Android.Resource.Layout.SimpleListItem2 it works.

I suspect this has something to do with this explanation.

So wouldn't it be good to pass the parameter ViewGroup parent to the delegate aswell, so it can be used to correctly inflate custom layouts in the callback?
I'm pretty new to this whole matter and I don't know what the current development status is or if I'm missing some pattern I could use.

Thanks in advance!