我有一个表格布局,我在其中显示数据库中的一些数据。我将表格布局的行保持为可单击,因为我想在用户单击该行后在列表视图中显示与该行相关的数据库中的所有详细信息。单击 m 后得到IllegalStateException ...
04-30 11:17:03.982: E/AndroidRuntime(9466): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:386)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.ArrayAdapter.getView(ArrayAdapter.java:362)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.ListView.measureHeightOfChildren(ListView.java:1246)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.ListView.onMeasure(ListView.java:1158)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.view.View.measure(View.java:15513)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
04-30 11:17:03.982: E/AndroidRuntime(9466): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
有人知道问题是什么吗?请帮忙!
列表视图代码:
settings = getSharedPreferences("LandTshare", MODE_PRIVATE);
prefEditor = settings.edit();
rowid=settings.getInt("rowid", 0);
WayDataBase way=new WayDataBase(getApplicationContext());
ArrayList<String> listvalues=way.getListDetails(rowid);
if(listvalues.size()!=0)
{
ListView lv=getListView();
ListAdapter adapter=new ArrayAdapter<String>(ListViewDetails.this, R.layout.view_animal_entry,listvalues);
lv.setAdapter(adapter);
}
view_animal_entry.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/animalId"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" />
<TextView
android:id="@+id/animalName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:paddingLeft="6dip"
android:paddingTop="6dip"
android:textColor="#A4C739"
android:textSize="17sp"
android:textStyle="bold" />
</LinearLayout>