-1
我正在使用帶遊標的方法返回具有相同ID的所有值,例如:停止.setText覆蓋?從數據庫遊標結果
ID_Owner | ID_Car
1 -------- 1
1 -------- 2
用id所有者,擁有了汽車1和2 ..
用我的方法IM返回這些值:
// Seleciona o Registo com o ID especeficado
public Cursor selectMotivosWhereId(long id){
String sql = "SELECT * FROM Motivo_sintomas WHERE _ID IN (SELECT id_motivo FROM Sintoma_motivos WHERE id_sintoma = ?) " ;
String[] args = new String[]{id + ""};
Cursor result = this.db.rawQuery(sql, args);
return result;
}
然後,我想向他們展示在同一個TextView的,但只顯示最後一個,我認爲它是因爲.setText覆蓋,只顯示最後一個。
Cursor res2 = dal.selectMotivosWhereId(position);
res2.moveToFirst();
while (!res2.isAfterLast()) {
Motivo.setText(res2.getString(res2.getColumnIndex(DBContract.Motivo_sintomas.COL_Motivo)));
res2.moveToNext();
}
我該如何向edittext添加值並用「 - 」或「,」分隔它們?
非常感謝。
謝謝!我怎樣才能在每個值之間添加逗號或「 - 」? –
對於顯示,您必須將結果存儲在兩個不同的變量(如ID_owner和ID_Car)中,然後以所需的格式顯示。 sb.append(ID_Owner + 「------」 + ID_CAR); – Prateek