これが私の活動です。
private ImageLoader testing;
testing = new ImageLoader(this);
imageview = (ImageView)findViewById(R.id.image_alllatestnewstitle);
...
...
...
これはリストビューなので、複数の画像が表示されます。
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);
これは私の ImageLoader クラスです
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);
}
}
これはxmlレイアウトです
<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" />
結果を印刷しました
url and bitmap
null ではなく、正しい URL リンクを表示します。
しかし、imagebitmapを設定すると、エラーは発生しませんでしたが、imageviewにも画像が表示されませんでした。
何が問題ですか?
p/s: 必要に応じて追加のコードをリクエストしてください。