i'm a beginner with Java and i would like to display web images on a ListView from JSON. For now i've create ListView with text strings and local image (mipmap.ic_launcher). Also loading img from web works, but only from onCreate using
mImageView = (ImageView) findViewById(R.id.image);
new LoadImageTask(this).execute(KEY_URL);
Rest of my code:
public void onLoaded(List<AndroidVersion> androidList) {
for (AndroidVersion wykopList : androidList) {
HashMap<String, String> map = new HashMap<>();
mImageView = (ImageView) findViewById(R.id.image);
new LoadImageTask(this).execute(KEY_URL);
map.put(KEY_VER, wykopList.getVer());
map.put(KEY_NAME, wykopList.getName());
map.put(KEY_API, wykopList.getApi());
map.put("image",String.valueOf(R.mipmap.ic_launcher));
mAndroidMapList.add(map);
}
loadListView();
}
private void loadListView() {
ListAdapter adapter = new SimpleAdapter(MainActivity.this, mAndroidMapList, R.layout.list_item,
new String[] { KEY_VER, KEY_NAME, KEY_API,"image" },
new int[] { R.id.version,R.id.name, R.id.api,R.id.image});
mListView.setAdapter(adapter);
}
@Override
public void onImageLoaded(Bitmap bitmap) {
mImageView.setImageBitmap(bitmap);
}