我正在为listview创建一个自定义的arrayAdapter,但是像我的超级构造函数这样的简单事情让我感到困惑!
private ArrayAdapter<ScheduleTime> timeHold;
//make proper constructor, see use ticket types
public TimeTableAdapter(Context context, int textViewResourceId,
ArrayAdapter<ScheduleTime> timesTable) {
super(context, textViewResourceId, timesTable);
this.timeHold = timesTable;
}
我在super
行上收到错误:
super(context, textViewResourceId, timesTable);
The constructor SimpleAdapter(Context, int, ArrayAdapter<ScheduleTime>) is undefined
我在这里缺少什么?我的上面的构造函数显然具有所有这些元素
答案 0 :(得分:2)
仅仅因为您定义的构造函数采用某个参数列表,并不意味着超类具有该构造函数。毕竟,您可以为构造函数定义任何仲裁参数列表。
您尝试调用的超级构造函数最接近ArrayAdapter类中的超级构造函数,但错误消息表明您尝试从SimpleAdapter继承。你有这个权利吗?如果它应该是ArrayAdapter,则最后一个参数需要是支持适配器的对象的数组(或List),而不仅仅是该类型的单个对象。
如果是SimpleAdapter,唯一的构造函数是 here,看起来有点不同。
答案 1 :(得分:1)
super
用于调用超类的构造函数,即您正在扩展的类。查看the documentation:SimpleAdapter
的构造函数有不同的参数。