I am trying to create a spinner in my code without using an xml layout at all. It seems that you need an ArrayAdapter with the spinner but the constructors all want a resource id in its set of constructors. Well, when not using XML layout i dont see how I can get a resource id.
Spinner spinner = new Spinner(this);
List<String> spinnerList = new ArrayList<String>();
spinnerList.add("Ice Cream Sandwich");
spinnerList.add("Hushpuppies");
spinnerList.add("Pickled Pigs Feet");
spinnerList.add("Cupcakes");
spinnerList.add("Chocolate Covered Pretzels");
ArrayAdapter<String> mySpinnerAdapter = new ArrayAdapter<String>(this, ??);
//spinner.setAdapter(mySpinnerAdapter);
how should i instantiate an ArrayAdapter here? thanks all in advance and hopefully i didn’t make anyone too hungry. 🙂
EDIT: i think i have it now – will test and see…
ArrayAdapter<String> mySpinnerAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, spinnerList);
mySpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(mySpinnerAdapter);
i was able to use the android.R.layout and a subclass to solve what i needed to here