【发布时间】:2014-10-24 16:42:20
【问题描述】:
我正在为我的 listView 制作自定义适配器,我收到此错误“构造函数 ArrayAdapter(Context, int, int[]) 未定义”
这是适配器代码:
class HeartlessAdapter extends ArrayAdapter<Integer>
{
Context context;
int[] images;
HeartlessAdapter(Context c, int[] imgs)
{
super(c, R.layout.imageview, imgs); //this is the line that has the error
this.context=c;
this.images=imgs;
}
class MyViewHolder
{
ImageView myImage;
MyViewHolder(View v)
{
myImage = (ImageView) v.findViewById(R.id.imageView);
}
}
有关如何解决此错误的任何提示,谢谢
【问题讨论】:
-
在构造函数中,你只有 2 个参数,即 Context c 和 int[] imgs。在你的 super() 中,你有 3 个项目。删除 R.layout.imageview。我找不到任何保留它的意义。
-
也描述一下你想做什么,这样我可以更好的解释在哪里使用R.layout.imageview
标签: java android listview android-arrayadapter