-1

您好,我想将表中的特定字段“位置”绑定到 android 中的微调器。这是我的代码..有人可以帮助我吗?

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);
4

2 回答 2

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 );
于 2013-08-26T15:11:30.213 回答
0

试试这个 int[] to=new int[] {android.R.id.text1};

于 2013-08-26T15:06:39.860 回答