0
我正在從事一個android項目,我應該從mysql數據庫中列出數據並設置圖像的src,當它位於ListView
內部時,圖像名稱取自可繪製資源。下面是設計ListView
的代碼,在數據庫中TAG_DRAP
是表明這樣@drawable/equip1
:Android將Imageview src動態地設置到列表視圖
protected void onPostExecute(String file_url) {
// dismiss the dialog after getting all products
pDialog.dismiss();
// updating UI from Background Thread
runOnUiThread(new Runnable() {
public void run() {
/**
* Updating parsed JSON data into ListView
* */
ListAdapter adapter = new SimpleAdapter(
AllProductsActivity.this, productsList,
R.layout.list_item_equipes, new String[] { TAG_PID,
TAG_NAME,TAG_DRAP,TAG_DRAP},
new int[] { R.id.pid, R.id.name,R.id.surname,R.id.icon });
//getResources().getIdentifier("TAG_DRAP", "drawable", context.getPackageName())
// updating listview
setListAdapter(adapter);
}
});
}