I'm facing this (for me) strange issue. After a couple of years of Xamarin Studio, I've opted to work with the plugin for VisualStudio 2015. I'm currently working on a project for field maintenance, so this is the first I've migrated. After having resolved some problems with the RecyclerView and CardView widgets, I'm facing this new issue, never seen with Xamarin Studio. I have this simple layout for a ViewHolder item, that uses a selector as background. This is the selector (res/color/item_bg_selector.xml) :
<?xml version="1.0" encoding="UTF-8" ?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true" android:color="#fffff2e6" />
<item android:state_selected="true" android:color="#ffabfdc3" />
<item android:color="@android:color/transparent" />
</selector>
This is the item layout (res/layout/rowSpare.xml) :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="@color/item_bg_selector">
<TextView
android:id="@+id/tvSpareCode"
android:layout_width="0dp"
android:layout_weight="@integer/spareCode"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvSpareDescription"
android:layout_width="0dp"
android:layout_weight="@integer/spareDescPrice"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvSparePrice"
android:layout_width="0dp"
android:layout_weight="@integer/sparePrice"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/tvSpareQuantity"
android:layout_width="0dp"
android:layout_weight="@integer/spareQuant"
android:layout_height="wrap_content"
android:gravity="right"
android:textColor="@color/black"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
This is the excerpt from my custom adapter where the error arises :
public class adSpareList : RecyclerView.Adapter
{
....
public override RecyclerView.ViewHolder OnCreateViewHolder(ViewGroup parent, int viewType)
{
View itemView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.rowSpare, parent, false);
itemView.Clickable = true;
SpareItemViewHolder vh = new SpareItemViewHolder(itemView, OnClick);
return (vh);
}
}
Whenever executed, the first line of the OnCreateView gives this error :
Unhandled Exception
Android.Views.InflateException: Bonary XML file line #1: Error inflating class <unknown>.
without other info. The same layout worked well on Xamarin Studio. If I remove android:background="@color/item_bg_selector", or I substitute it with a simple android:background="@android:color/transparent" the whole thing works without error, but it's not the result I achieved before. Any help would be very appreciate.
Rodolfo.