You must supply a resource ID for a TextView android error You must supply a resource ID for a TextView android error arrays arrays

You must supply a resource ID for a TextView android error


I'm pretty sure the problem lies in your conversation_item layout. The docs state that you must provide a resource with a single TextView. What does that layout look like?

As an example, this is what the simple_list_item_1 layout looks like, yours should be pretty similar.

<?xml version="1.0" encoding="utf-8"?><TextView xmlns:android="http://schemas.android.com/apk/res/android"    android:id="@android:id/text1"    android:layout_width="fill_parent"    android:layout_height="wrap_content"    android:textAppearance="?android:attr/textAppearanceLarge"    android:gravity="center_vertical"    android:paddingLeft="6dip"    android:minHeight="?android:attr/listPreferredItemHeight"/>

EDIT:

I just edited the question so your layout will show. Your layout is indeed wrong, you cannot have the linear layout there if you're using that constructor. You can use the other constructor ( ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects) ) and provide your custom layout and your TextView's id.


Had the same problem, needed to change the custom adapter from:

  ListAdapter adapter = new ArrayAdapter<String>(            this,            R.layout.conversation_item,            chatList        );    getListView().setAdapter(adapter);

to:

  ListAdapter adapter = new ArrayAdapter<String>(            this,            R.layout.conversation_item,            R.id.sometextview_from_the_layout,            chatList        );    getListView().setAdapter(adapter);

I think the selected TextView will be used to generate the rowid, which may explain its need to be unique, but I'm not sure yet.


It is better to use a custom adapter whenever a Array Of Objects need to be listed in a Custom Layout View. Refer this simple and beautiful referencePopulating a List View with a Custom Adapter