I need a dynamic string-array. All the examples I have seen show hard-coded string-arrays. Basically I have a list of years for the user to select. The years are hard coded, but unfortunately current year will not be a relevant choice next year. I don’t want to push updates for this in the future this could be dynamically generated with some kind of system call of the current year + X amount of years in the future for the rest of the list.
I am not sure how to make variables edit the XML, any insight appreciated
Clarification:
I have edited the Res>Values>strings.xml to have a list of years. I manually typed years in the list-item,
it would be:
list-item 2011
list-item 2012
list-item 2013……….
but in the year 2012, older years will not be relevant so I would need this string array regenerated. Is there a way to make the typed years be variables?
such as it would be:
list-item YEAR
list-item YEAR+1
list-item YEAR+2
and a function in the java will let the list know what those values really are, or something
I’m not sure what the problem is. Perhaps you’re not sure how to do in Java something that you were previously doing in XML?
Creating an
ArrayListof years is simple. This can back aListViewor aSpinnerby using anArrayAdapter.