标签:
1、ArrayAdapter requires the resource ID to be a TextView问题
listView.setAdapter(new ArrayAdapter<String>( this,R.layout.textlayout, strs ));
布局容易出现:ArrayAdapter requires the resource ID to be a TextView 报错
textlayout.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:id="@+id/text1" android:textSize="16sp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout>
问题出在:
<?xml version="1.0" encoding="utf-8"?> <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/text1" android:textSize="16sp" android:textStyle="bold" android:layout_width="fill_parent" android:layout_height="wrap_content"/>
xmlns:android=http://schemas.android.com/apk/res/android 就是这句了....
添加到自己的TextView中就ok.
因为根节点必须是TextView
标签:
原文地址:http://www.cnblogs.com/xtreme/p/5658243.html