Fearghal
Fearghal

Reputation: 11407

can a custom spinner adapter take a arraylist as parameter

I hold some bundles in arraylists of arraylists 'ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();'

This leads to an issue with the super method in the constructor. It doesnt like anything outher than objects or lists passed to it.

Can I use arrayList or must i cast it to object or list?

    public class Game_AddFixtures_SpinnerAdapter extends ArrayAdapter<String> {
        ArrayList<ArrayList<String>> fixtureDetails = new ArrayList<ArrayList<String>>();
        ArrayList<ArrayList<String>> list = new ArrayList<ArrayList<String>>();

        private Context c;
        public Game_AddFixtures_SpinnerAdapter (Context context, int textViewResourceId, ArrayList<ArrayList<String>> objectList) {
            super(context, textViewResourceId, objectList); //ERROR HERE
            // TODO Auto-generated constructor stub
            this.c = context;
            this.list =objectList;
        }
}

error:

cannot resolve method 'super(android.content.context, int, java.util.arraylist>)

Upvotes: 0

Views: 239

Answers (1)

Satyen Udeshi
Satyen Udeshi

Reputation: 3243

Yes can take, just change this in your code

public class Game_AddFixtures_SpinnerAdapter extends ArrayAdapter<ArrayList<String>>

The reason here is super constructor is looking for String in the argument ,but you are passing ArrayList<String>. You need to extend ArrayList<String> to pass List of ArrayList.

Hope this clears the thing..

Upvotes: 1

Related Questions