I have developed the following for loop to set the data in a drop down list. This works perfectly if I use a number on the .get()
method to select and compare which item has been clicked, but obviously this is useless with a set integer value.
I'm getting the error that the 'a' variable cannot be resolved to a variable.
I'm really not sure why though?
Here's the code:
List<String> list = new ArrayList<String>();
list.add("-");
list.add("Medical");
list.add("Business");
list.add("Family");
list.add("Other");
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
editTime.setAdapter(dataAdapter);
for(int a = 0; a < list.size(); a ++);
{
// Error on the 'a' variable - cannot be resolved to a variable.
if(typeReturned == list.get(a));
{
// Error on the 'a' variable - cannot be resolved to a variable.
editTime.setSelection(a);
}
}