In my page, I have two spinner i want to show value from SQLite database. I can easily show a value in edit text. But i dont know how to show in spinner.
I tried like this:
String addr_country = rs.getString(rs.getColumnIndex(DBHelper.ADDRESS_COLUMN_COUNTRY));
country.setText((CharSequence) addr_country);
But its not working.. How to do
Try in this way:
String[] list = //get data from your database
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, list);
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner2.setAdapter(dataAdapter);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.