I have a class PictureArrayAdapter that extends ArrayAdapter<Pair<String, ImageInitialiser>> and has the following constructor:
public PictureArrayAdaptor(Context context, Pair<String, ImageInitialiser>[] values)
We have explicitly declared that when this constructor is called, the programmer has to pass a Pair<String, ImageInitialiser>[], otherwise a type error may occur. Now, producing such an object without a warning is rather difficult:
@SuppressWarnings("unchecked")
Pair<String, ImageInitialiser> tableData[] = new Pair[1];
tableData[0]=new Pair<String, ImageInitialiser>("A", new ResourceImageInitialiser(R.drawable.sample1));
One possibility would be to use a list instead. However, for the sake of consistency, I'd like to keep all the constructors exactly the same as the base class. Is there a nicer way of calling this constructor? I really don't think that this is how it is supposed to be called.
public PictureArrayAdaptor(Context context, Pair<String, ImageInitialiser>... values)an option?...is "syntactic sugar" on top of a simple array.