2013-12-13 22 views
0

現在我快寫完我的應用程序了。我需要的只是一個幫助,通過簡單的遊標適配器從我的數據庫中填充一個spinner中的選定字符串值。我不知道如何從我的微調框中獲取字符串,並將其傳遞給不同的遊標,並在查詢中使用該字符串,該字符串將根據微調框的第一選擇填充,以此類推其他旋鈕。作爲字符串的新光標選定的微調項目

這裏是我用於我的一個紡紗廠的代碼。

vType = (Cursor) DataBaseHelper.getPowersportsType(); 
    this.startManagingCursor(vType); 

     SimpleCursorAdapter scaType = new SimpleCursorAdapter(this, 
       android.R.layout.simple_spinner_item, 
       vType, 
       new String [] {DataBaseHelper.POWERSPORTS_TYPE}, 
       new int[] {android.R.id.text1}); 

     scaType.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
     vTypeSpinner = (Spinner) findViewById(R.id.typeSpinner); 
     vTypeSpinner.setAdapter(scaType); 

而且這是在我的XML佈局我下一個微調查詢

static String MakeWhere = "POWERSPORTS_TYPE=?"; 
public static Cursor getPowersportsMake(){ 
return myDataBase.query(POWERSPORTS_TABLE, 
    new String [] {POWERSPORTS_ID, POWERSPORTS_MAKE}, 
    MakeWhere, 
    null, 
    POWERSPORTS_MAKE, 
    null, 
    null); 
} 

任何意見或建議,歡迎。

回答

1

獲得該項目選擇您需要設置onItemSelectedListener

然後在onItemtSelected所有你會做的是

String selection = vTypeSpinner.getSelectedItem().toString(); 
+0

那麼我將如何使用在微調選擇作爲變量的字符串在我的疑問? – LukeG224