Android Dynamic Spinner
private void createSpinner() {
ll.addView(s);
SQLiteDatabase db = dbs.getReadable开发者_Python百科Database();
String SQL = "SELECT * FROM Test where password = 'S'";
final Cursor cursor = db.rawQuery(SQL, null);
startManagingCursor(cursor);
final int l = cursor.getCount();
array_spinner = new String[l];
int i = 0;
while (cursor.moveToNext()) {
array_spinner[i]= cursor.getString(1);
i ++;
}
final ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, array_spinner);
s.setAdapter(adapter);
cursor.close();
ll.addView(submit);
submit.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
for(int i = 0; i < l; i++) {
}
}});
}
In this code i want the user to select the value in the spinner which is sent from the database. And then when the user clicks on the submit button i want that value selected to be saved to the database...i am wondering what the selected spinner option function is...is there a adapter.selected() r checked or a spinner.selected function available? hope i am explaining it correctly thanks
Its spinner.getSelectedItem().toString()
精彩评论