0
我有一個使用簡單的遊標適配器填充數據庫的列表視圖,裏面有2個textviews。我想在列表中的每個項目內添加一個圖像,並使用數據庫中的相應圖像。我已經搜索了這個主題,但還沒有找到解決方案。任何幫助將不勝感激如何添加一個圖像到我的listview在android中?
String[] from = new String[]{InventoryDbAdapter.KEY_TITLE, InventoryDbAdapter.KEY_DESCRIPTION};
// and an array of the fields we want to bind those fields to (in this case just text1)
int[] to = new int[]{R.id.text1,R.id.text2};
// Now create a simple cursor adapter and set it to display
SimpleCursorAdapter inventory =
new SimpleCursorAdapter(this, R.layout.row, InventoryCursor, from, to);
setListAdapter(inventory
感謝
我以前見過那個教程,但是我沒看到這個教程是如何與數據庫相關的,它只是將一些東西添加到數組列表中 – waa1990 2011-03-13 05:27:18
從你的問題中根本不清楚。它的標題是「如何在Android中將圖像添加到我的列表視圖中?」 (真的沒有提到數據庫);您通常不會將圖像存儲在數據庫中,而是將它們的路徑和圖像放入資產目錄中,然後可以按照上述教程的說明進行訪問和使用。 – 2011-03-13 05:37:11
我沒有在數據庫中存儲他們的路徑我想我沒有足夠的經驗與listiews完全理解該教程。 – waa1990 2011-03-13 05:39:47