0

您好我正在尝试实现自定义适配器。我收到以下错误:

03-16 05:23:22.003: E/AndroidRuntime(316): FATAL EXCEPTION: main
03-16 05:23:22.003: E/AndroidRuntime(316): java.lang.IllegalStateException: ArrayAdapter requires the resource ID to be a TextView

这就是我尝试填充我的 ListView 的方式:

    CustomListViewAdapter adapter = new CustomListViewAdapter(context, R.layout.list_item, rowItems);

这是我得到错误的地方。

我在网上看到很多答案说你需要传入一个TextView,但我希望每一行都有一个图像和两个TextView。我正在关注本教程http://theopentutorials.com/tutorials/android/listview/android-custom-listview-with-image-and-text-using-arrayadapter/并且他们的自定义布局工作正常,它不会抱怨. 我对每一行都使用了他们在教程中使用的相同自定义布局。为什么我在抱怨

4

1 回答 1

0

在您的代码中检查以下一项

public class CustomListViewAdapter extends ArrayAdapter<RowItem>

你写过 RowItem 吗?您可能忘记更改ArrayAdapter<String>ArrayAdapter<RowItem>

于 2013-03-16T07:53:01.850 回答