自定义ArrayAdapter中未定义java构造函数
我知道这个问题已经解决了一百万次,是的,我已经搜索过了,但它对我不起作用
问题是方法super不需要正确的参数
守则:
public class QuotesArrayAdapter extends ArrayAdapter<Map<Integer,List<String>>> {
private Context context;
Map<Integer,List<String>> Values;
static int textViewResId;
Logger Logger;
public QuotesArrayAdapter(Context context, int textViewResourceId, Map<Integer,List<String>> object) {
super(context, textViewResourceId, object); //<---- ERROR HERE
this.context = context;
this.Values = object;
Logger = new Logger(true);
Logger.l(Logger.TAG_DBG, "ArrayAdapter Inited");
}
Eclipse所说的:
Multiple markers at this line
- The constructor ArrayAdapter<Map<Integer,List<String>>>(Context, int, Map<Integer,List<String>>)
is undefined
- The constructor ArrayAdapter<Map<Integer,List<String>>>(Context, int, Map<Integer,List<String>>)
is undefined
它需要super(Context,int)而这不是我想要的
# 1 楼答案
另外,您可以使用
Arrays.asList(..)
# 2 楼答案
看看^{} 可用的构造函数
这些都与你的论点不符
你打算调用哪一个?这里的
T
是Map<Integer,List<String>>
,但构造函数的object
参数正是这种类型。如果您想要使用一个需要集合的构造函数,您需要从您拥有的单个对象构建该集合最简单的方法可能只是使用:
# 3 楼答案
很简单,ArrayAdapter中没有接受映射的构造函数
您需要将其转换为列表或基本数组,如果这两个选项都不起作用,那么您将不得不扩展BaseAdapter