8

Populate spinner with years dynamically in Android?

view full story
linux-howto

http://stackoverflow.com – I have been racking my brain trying to get this to work. I want to dynamically enter in years from 1900 to the current year into a spinner. I don't think that this is possible to do using an XML defined array but can I do it with an array adapter? Here is what I have so far: ArrayList<String> years = new ArrayList<String>(); int thisYear = Calendar.getInstance().get(Calendar.YEAR); for (int i = 1900; i <= thisYear; i++) { years.add(i); } adapter = new ArrayAdapter<String>(this, android.R.layout.simple_s (HowTos)