我有一個列表視圖,其中填充了來自我的數據庫的數據。我使用simpleCursorAdapter來顯示值。獲取SimpleCursorAdapter中的外鍵值
我有一個表,我可以加課:英語,法語......
在另一張表,我可以創建developped課(我加開始和結束,這天的日期,主題爲教訓)。我必須以FK的身份提供這個教訓。
當我添加一個課程時,在我的listView中,我想顯示每個示例:英語 - 閱讀,但它顯示1 - 閱讀。因爲1是我在第二張表中存儲的值。
如何將1改爲英文?
這裏是我的代碼:
Cursor cursor = dbhelper.getAllCours();
String[] from = { "branche_cours", "designation" }; //here 'branche_cours' is the lesson i store as an INT, it's the FK so
int[] to = { R.id.text_branche_cours, R.id.text_designation };
adapter = new SimpleCursorAdapter(this, R.layout.list_row, cursor, from, to, 0);
lvCours.setAdapter(adapter);
adapter.notifyDataSetChanged();
我使用getAllCours()
public Cursor getAllCours()
{
//from here, i retrieve the ID, designation and branche_cours
String Query = ("select ID as _id, date_debut, date_dernier, dixieme_point, " +
"demi_point, description, designation, lundi, mardi, mercredi, jeudi," +
" vendredi, samedi, branche_cours from " + TABLE_COURS);
Open();
Cursor cursor = db.rawQuery(Query, null);
return cursor;
}
我如何可以鏈接的int實際價值(所以如何能在 '1' 變成「英語的方法「)?
我還沒有找到解決辦法.. – David