This is probably a simple straight forward thing to do for some.
I have this code...
SQLiteDatabase db = dbs.getReadableDatabase();
String SQL = "SELECT * FROM Table";
final Cursor cursor = db.rawQuery(SQL, null);
array_spinner1[0] = "Select:";
while (cursor.moveToNext()) {
array_spinner1[i]= cursor.getString(1) + " - " + cursor.getString(2);
i ++;
}
final ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, array_spinner1);
s1.setAdapter(adapter);
I populate the array and everything runs fine. However, i want to start the position of the spinner not at the first item(Select). I want it to start where the item in the cursor = 'here' for example. I hope i made sense?
To put it into context in 'Table' column 1 is age range from and column 2 is age range to. so in the spinner i get 0-5, 6-10, 11-20 etc
and what i want to do is start the spinner selected at 11-20 if the user's d.o.b makes him that age....? I know setSelection would select a certain value, but i need to work out the correct one for the users age?
So i basically want to know how to work that out and populate select the spinner correctly, thanks