I am working on a android project where I should list data from a mysql database and set an image's src when it is inside a ListView
, the name off the image is taken from the drawable resources. Here's the code for designing the ListView
, the TAG_DRAP
in the database is show like this @drawable/equip1
:
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);
}
});
}