您好我想将特定字段'location'从我的表绑定到android中的spinner。这是我的代码..任何人都可以帮助我吗?
Cursor cur=db.getdata();
String[] columns=new String[]{DatabaseHandler.KEY_LOCATION};
int[] to=new int[] {R.id.text_location};
//ArrayAdapter<String> adapter=new ArrayAdapter<String>(Next.this,android.R.layout.simple_spinner_item);
SimpleCursorAdapter sc=new SimpleCursorAdapter(this,android.R.layout.simple_spinner_item,cur,columns,to,0);
sc.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(sc);
答案 0 :(得分:0)
试试这个 int [] to = new int [] {android.R.id.text1};
答案 1 :(得分:0)
Cursor cur=db.getdata();
String[] columns=new String[]{DatabaseHandler.KEY_LOCATION};
int[] to=new int[] {R.id.text_location};
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_spinner_item,
cur,
columns,
new int[] { android.R.id.text1 });
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
sp.setAdapter(adapter );