Reputation: 143
I know this has been solved a million times and yes i have searched, but it doesn't work for me.
The problem is that method super doesn't want proper arguments.
The code:
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");
}
What Eclipse says:
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
It wants super(Context, int) and that's not what i want
Upvotes: 0
Views: 2058
Reputation: 77904
In additional you can use Arrays.asList(..)
public QuotesArrayAdapter(Context context, int textViewResourceId, Map<Integer,List<String>> object) {
super(context, textViewResourceId, Arrays.asList(object));
....
Upvotes: 1
Reputation: 86948
Quite simply there is no constructor in ArrayAdapter that takes a Map...
You need to convert it into a List or primitive Array, if neither of those options work then you will have to extend BaseAdapter instead.
Upvotes: 1
Reputation: 1500495
Look at the constructors available for ArrayAdapter
.
ArrayAdapter(Context context, int textViewResourceId)
ArrayAdapter(Context context, int resource, int textViewResourceId)
ArrayAdapter(Context context, int textViewResourceId, T[] objects)
ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)
ArrayAdapter(Context context, int textViewResourceId, List<T> objects)
ArrayAdapter(Context context, int resource, int textViewResourceId, List<T> objects)
None of those matches your arguments.
Which one did you intend to invoke? Your T
here is Map<Integer,List<String>>
, but your constructor's object
parameter is of exactly that type. If you want to use one of the constructors which requires a collection, you need to build that collection from that single object you've got.
The simplest approach is probably just to use:
public QuotesArrayAdapter(Context context, int textViewResourceId,
Map<Integer,List<String>> object) {
super(context, textViewResourceId);
add(object);
...
}
Upvotes: 5