This is my activity.
private ImageLoader testing;
testing = new ImageLoader(this);
imageview = (ImageView)findViewById(R.id.image_alllatestnewstitle);
...
...
...
This is in listview, so it will display multiple images.
private void filldata() {
lv = (ListView) findViewById(android.R.id.list);
String[] from = new String[] { "particularlatestnewstitle",
"newscategorytitle", "newsdate" };
int[] to = new int[] { R.id.text_particularlatestnewstitle,
R.id.text_newscategorytitle, R.id.text_newsdate };
fillMaps = new ArrayList<HashMap<String, String>>();
for (int i = 0; i < webservice.news.size(); i++) {
HashMap<String, String> map = new HashMap<String, String>();
map.put("particularlatestnewstitle", webservice.news.get(i)
.getNtitle());
map.put("newscategorytitle", webservice.news.get(i).getNewCatName());
map.put("newsdate", webservice.news.get(i).getNArticalD());
fillMaps.add(map);
imageview = (ImageView)findViewById(R.id.image_alllatestnewstitle);
imageview.setTag(imagepath[i]);
testing.DisplayImage(imagepath[i], imageview);
}
SimpleAdapter adapter = new SimpleAdapter(this, fillMaps,
R.layout.main_alllatestnewslist, from, to);
lv.setAdapter(adapter);
This is my ImageLoader class
public void DisplayImage(String url, ImageView imageView)
{
imageViews.put(imageView, url);
Bitmap bitmap=memoryCache.get(url);
if(bitmap!=null){
System.out.println(url.toString());
System.out.println(bitmap.toString());
imageView.setImageBitmap(bitmap);
}else
{
queuePhoto(url, imageView);
}
}
This is the xml layout
<ImageView
android:id="@+id/image_alllatestnewstitle"
android:layout_width="134px"
android:layout_height="80px"
android:layout_marginBottom="5px"
android:layout_marginLeft="10px"
android:layout_marginRight="10px"
android:layout_marginTop="5px"
android:scaleType="centerCrop" />
I was print the result
url and bitmap
Both not null and display correct url link.
But when setimagebitmap, it got no error but the imageview also did not display the image.
What is the problem?
p/s: Request for more code if you need.
I am sure you are using Lazy loading logic of Fedor.
And now, based on the code you have provided i can say one thing, i.e. You forgot to set TAG to your ImageView before calling DisplayImage() method.