-1
我有一個包含如何在android中使用sqlite綁定微調框?
------------------------
id |Name
------------------------
16001 |ABC
16002 |QWE
16003 |RTY
16004 |JHG
並將其綁定到一個旋轉器的表。帶名稱的微調器項目,以及帶ID的微調項目。
我試試這個至今:
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, lables);
// Drop down layout style - list view with radio button
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
List<String> lables = dataSource.getAllmothers();
public List<String> getAllmothers()
{
List<String> labels = new ArrayList<String>();
database = dbHelper.getReadableDatabase(); // Select All Query
String selectQuery = "SELECT id,name FROM "+dbHelper.TABLE_REGISTRATION;
Cursor cursor = database.rawQuery(selectQuery, null); // looping through all rows and adding to list
if (cursor.moveToFirst()) {
do
{
labels.add(Integer.toString(cursor.getInt(0)));
labels.add(cursor.getString(1));
} while (cursor.moveToNext());
} // closing connection
cursor.close();
database.close(); // returning lables
return labels;
}
先試試自己,然後在這裏問你是否遇到任何問題。 – Riser
以及到目前爲止嘗試過的東西? –
我也試過 –