2012-04-02 28 views
0

インターネットから以前にダウンロードしたイメージといくつかの情報を含むリストビューを表示しようとしています。テキスト情報は素晴らしいですが、イメージビューは表示されません。私のコードは次のとおりです。リストビューにビットマップが表示されない

@Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     Log.w("MyApp", "Getting View"); 

     View row = convertView; 

     if(row==null){ 
       LayoutInflater inflater=getLayoutInflater(); 
       row=inflater.inflate(R.layout.list_item, parent, false); 
     } 

     ImageView showcase = null; 

     try{ 
      showcase = new ImageView(ReadingList.this); 
     }catch(Exception e){ 
      Log.w("MyApp", e.toString()); 
     } 

     if(showcase!=null){ 
      BitmapFactory.Options options = new BitmapFactory.Options(); 
      options.inSampleSize = 3; 

      Bitmap bm = null; 

      File dir = new File(PATH + urlIDs[position]); 

      if(dir.isDirectory()){ 
       Log.w("MyApp","Dir is a directory"); 
       for (File child : dir.listFiles()) { 
         String path = child.getAbsolutePath(); 
         Log.w("MyApp", path); 
         bm = BitmapFactory.decodeFile(path, options); 
         Log.w("MyApp", "See if bm is null"); 
         if(bm!=null){ 
          Log.w("MyApp", "bm!=null"); 
          showcase.setImageBitmap(bm); 
          break; 
         } 
         } 
      } 

     } 

     TextView title =(TextView)row.findViewById(R.id.list_item_text); 
     TextView url = (TextView) row.findViewById(R.id.list_item_url); 
     title.setText(Titles[position]); 
     url.setText(urlPrefixes[position]); 

     return row; 
    } 
} 

それは現時点では少し厄介だ申し訳ありません..私はそれがそのフォルダ内の画像は、それがbm!=nullチェックに合格見つけるとlogcatに見ることができる、とのようにそのイメージを設定する必要があります私が間違っていない場合、画像の内容を見る。私はlogcatでそれが次の行項目に移動したことを見ることができます。そして、eclipseファイルマネージャを使用して、受信したパスの最後に実際に画像があることを確認できます。child.getAbsolutePath

私は何ですか?間違っている?

答えて

1

私は間違っていますか?

がリストアイテムビューに接続されていません。代わりにリストアイテムビュー内のそのビューを見つけてください。

ImageView showcase = (ImageView) row.findViewById(R.id.my_icon); 
関連する問題