2014-06-06 23 views
0

我使用通用图像加载器来显示缩略图在我的列表查看,但是当我快速向上/向下滚动图像得到互换这是烦人请帮助我通过它.. 谢谢 我的DisplayImage配置:ListView图像不显示在他们的顺序

DisplayImageOptions displayimageOptions = new DisplayImageOptions.Builder().cacheInMemory(true).bitmapConfig(Bitmap.Config.RGB_565). 
      delayBeforeLoading(1000) .cacheOnDisc(true).imageScaleType(ImageScaleType.EXACTLY) 
      .resetViewBeforeLoading().build(); 

而且ImageLoader的配置:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext()) 
    .threadPoolSize(15) 
    .threadPriority(Thread.NORM_PRIORITY) // default 
    .tasksProcessingOrder(QueueProcessingType.FIFO) // default 
    .memoryCacheSize(20 * 1024 * 1024) 
    .memoryCacheSizePercentage(25) // default 
    .discCacheSize(20 * 1024 * 1024) 
    .discCacheFileCount(100) 
    .discCacheFileNameGenerator(new HashCodeFileNameGenerator()) // default 
    .build(); 

    ImageLoader.getInstance().init(config); 

适配器的getView():

public View getView(int position, View convertView, ViewGroup parent) { 
    View vi=convertView; 
    if(convertView==null){ 
     vi = inflater.inflate(R.layout.list_layout, null); 
    } 
    TextView title = (TextView)vi.findViewById(R.id.tv2); // title 
    final ImageView thumb_image=(ImageView)vi.findViewById(R.id.img); // thumb image 

    HashMap<String, String> song = new HashMap<String, String>(); 
    song = data.get(position); 

    // Setting all values in listview 
    title.setText(song.get(DisplayMessage.KEY_TITLE)); 
    Log.w(null, song.get(DisplayMessage.KEY_THUMB_URL)); 
    ImageLoader imageLoader = ImageLoader.getInstance(); 
    Log.w("null",song.get(DisplayMessage.KEY_THUMB_URL)); 
    ImageSize targetSize = new ImageSize(70, 70); 
    final ImageAware imageAware = new ImageViewAware(thumb_image, false); 
    // Utils.imageLoader.displayImage("file:///"+song.get(DisplayMessage.KEY_THUMB_URL), imageAware); 
    imageLoader.loadImage("file:///"+song.get(DisplayMessage.KEY_THUMB_URL), targetSize, new SimpleImageLoadingListener() { 
     @Override 
     public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { 
      // Do whatever you want with Bitmap 
      imageAware.setImageBitmap(ThumbnailUtils.extractThumbnail(loadedImage, 70, 70)); 
     } 
    }); 

    return vi; 
} 

回答

-1

在您的getView()方法中,只需删除此if(convertView==null)条件并尝试再次运行。只要做到像如下─

public View getView(int position, View convertView, ViewGroup parent) { 
View vi=convertView; 
//if(convertView==null){ 
    vi = inflater.inflate(R.layout.list_layout, null); 
//} 
TextView title = (TextView)vi.findViewById(R.id.tv2); // title 
final ImageView thumb_image=(ImageView)vi.findViewById(R.id.img); // thumb image 

HashMap<String, String> song = new HashMap<String, String>(); 
song = data.get(position); 

// Setting all values in listview 
title.setText(song.get(DisplayMessage.KEY_TITLE)); 
Log.w(null, song.get(DisplayMessage.KEY_THUMB_URL)); 
ImageLoader imageLoader = ImageLoader.getInstance(); 
Log.w("null",song.get(DisplayMessage.KEY_THUMB_URL)); 
ImageSize targetSize = new ImageSize(70, 70); 
final ImageAware imageAware = new ImageViewAware(thumb_image, false); 
// Utils.imageLoader.displayImage("file:///"+song.get(DisplayMessage.KEY_THUMB_URL), 
imageAware); 
imageLoader.loadImage("file:///"+song.get(DisplayMessage.KEY_THUMB_URL), targetSize, new  
SimpleImageLoadingListener() { 
    @Override 
    public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { 
     // Do whatever you want with Bitmap 
     imageAware.setImageBitmap(ThumbnailUtils.extractThumbnail(loadedImage, 70, 70)); 
    } 
}); 
return vi; 
} 
+0

试过太多,但没有运气!..我现在用的毕加索和现在的图像完美的罚款..anyway感谢答复 – kalimba

+0

@kalimba好吧......我也不要使用装ImageLoader的。但很好,你的问题解决了。 快乐编码:) – Priyanka

相关问题