【发布时间】:2013-04-29 09:23:25
【问题描述】:
参考以下代码。我想知道为什么我需要放入一个对象而不是字符串中的所有对象。此代码来自自定义 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;
}
【问题讨论】:
-
super调用您正在扩展的类的构造函数,如果您查看您提供的链接,您会发现它不存在。