2012-05-07 20 views
0

これは私の活動です。画像が表示されません。URLが画像ビューに設定されています。

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); 

これはこれは私が

url and bitmap 

ヌルどちらもない結果を印刷して、正しいURLが表示された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" /> 

にある

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); 
    } 
} 

私ImageLoaderクラスですリンク。

しかし、setimagebitmapを実行してもエラーは発生しませんでしたが、画像ビューも画像を表示しませんでした。

何が問題ですか?

p/s:必要に応じて、より多くのコードをリクエストしてください。

答えて

0

私はあなたがFedorの遅延読み込みロジックを使用していると確信しています。

あなたが提供したコードに基づいて、私はDisplayImage()メソッドを呼び出す前にImageViewにTAGを設定するのを忘れたということを言います。

testing.setTag(imagepath[i]); 
+0

ImageLoaderにはこの機能がありません。 –

+0

@AlanLai FYIの組み込み関数です。 –

+0

どのようにそれを呼び出すには? それは 'imageview.setTag(のImagePath [i])と –

0

donwload imageためにこのコードを試してみて、imageviewに画像を設定します。

 try { 
      URL url = new URL(urlStr); 
      URLConnection ucon = url.openConnection(); 

      InputStream is = ucon.getInputStream(); 
      Bitmap bitmap = BitmapFactory.decodeStream(is); 
      if(bitmap!=null){ 
       System.out.println(url.toString()); 
       System.out.println(bitmap.toString()); 
       imageView.setImageBitmap(bitmap); 
      } 
     } catch (MalformedURLException e1) { 
      e1.printStackTrace(); 
     } catch (IOException e) { 
      // TODO Auto-generated catch block 
      e.printStackTrace(); 
     } 
+0

これは現在のものです。これは現在のものです。 –

+0

これはlistview、それはあなたの問題を解決する可能性がありますoutofmemory –

+0

の遅延読み込みの概念を使用する可能性があります。 –

関連する問題