参考以下代码。我想知道为什么我需要放入一个对象而不是字符串中的所有对象。此代码来自自定义ListView适配器。
public ArrayAdapter (Context context, int textViewResourceId, T[] objects)
工作正常
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
如果我这样做会出错。
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first, second, third);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
错误:构造函数ArrayAdapter(Context,int,String [],String [],String [])未定义
原始资料
public class ListViewAdapter extends ArrayAdapter<String> {
Context context;
String[] first;
String[] second;
String[] third;
LayoutInflater inflater;
public ListViewAdapter(Context context, String[] first, String[] second, String[] third) {
super(context, R.layout.listview_item, first);
this.context = context;
this.first = first;
this.second = second;
this.third = third;
}
答案 0 :(得分:2)
您应该阅读Java中inheritance的原理。您的课程正在延长ArrayAdapter。
如果你看一下它,你会发现没有为这个类定义ArrayAdapter(Context, int, String[], String[], String[])
类型的构造函数。
这就是你无法做super(context, R.layout.listview_item, first, second, third);