2011-05-25 58 views
0

在GridView中使用Droidfu的小部件WebImageView創建圖庫。圖像是通過WebImageView異步下載並緩存的。Droidfu WebImageView和GridView問題

問題是,當網格滾動到它時,id並不總是顯示圖像(它顯示默認錯誤img)。這就像getView正在銷燬它,並且無法正確地回收它。

這是我GridAdapter

公共類GalleryAdapter延伸BaseAdapter {

private Context mContext; 

    public GalleryAdapter(Context c) { 
     // TODO Auto-generated constructor stub 
     mContext = c; 
    } 

    @Override 
    public int getCount() { 
     // TODO Auto-generated method stub 
     return theList.getItemCount(); 
    } 

    @Override 
    public Object getItem(int arg0) { 
     // TODO Auto-generated method stub 
     return theList.getItem(arg0); 
    } 

    @Override 
    public long getItemId(int arg0) { 
     // TODO Auto-generated method stub 
     return arg0; 
    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     // TODO Auto-generated method stub 

     final GalleryItem galeryItem = theList.getItem(position); 

     if (convertView == null) { 
      convertView = (View) getLayoutInflater().inflate(R.layout.gallery_item, parent, false); 

     } 

     WebImageView imageView = (WebImageView) convertView.findViewById(R.id.webimage); 

     if (!galeryItem.getMain_image().trim().equalsIgnoreCase("")) { 

      imageView.setScaleType(ScaleType.CENTER_CROP); 
      imageView.setAdjustBounds(true); 
      imageView.reset(); 
      imageView.setImageUrl(galeryItem.getMain_image().trim()); 
      imageView.setNoImageDrawable(R.drawable.heading_img_bg); 
      imageView.loadImage(); 
     } 

     TextView heading = (TextView) convertView.findViewById(R.id.gallery_heading); 
     heading.setText(galeryItem.getHeading()); 

     TextView img_num = (TextView) convertView.findViewById(R.id.gallery_img_num); 
     img_num.setText(Integer.toString(galeryItem.getImage_num())); 

     return convertView; 
    } 

} 

回答

0

this,對Droid的福發展會停下來,將 '改名爲' Ignition

點火有一個類似RemoteImageView的類。用法基本上是一樣的,但似乎他們已經重新設計了一下後端。我試着用一個ListView來給永久加載的問題。爲我工作(雖然它引入了一些其他問題)。

你可以試一試,看看你的問題是否已經解決。