I have a ListFragment with custom row as follows.
Fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top|center"
android:orientation="vertical"
android:background="@color/colorAppBackground">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
Custom_row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Small Text"
android:id="@+id/rootCategory_TextView"
android:textStyle="bold"
android:padding="10dp"
android:textColor="@color/rootCategoryText"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/subCategory_RecyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="horizontal" />
</LinearLayout>
I am getting following error:
ArrayAdapter requires the resource ID to be a TextView
.....
android.widget.LinearLayout cannot be cast to android.widget.TextView
It works fine if i remove LinearLayout ViewGroup from Custom_row.xml and just directly add textView but but my custom row needs more than one view and I have tired using all types of ViewGroups but they all give the above cast error