2

我在 ListView 中使用 Universal Image Loader,它第一次完美运行,但其余时间,图像没有圆角。仅当我滚动图像再次具有圆形边框时。

这是我的代码:

ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
            context).threadPriority(Thread.NORM_PRIORITY - 2)
            .denyCacheImageMultipleSizesInMemory()
            .discCacheFileNameGenerator(new Md5FileNameGenerator())
            .tasksProcessingOrder(QueueProcessingType.LIFO).enableLogging() 
            .build();
    // Initialize ImageLoader with configuration.
    ImageLoader.getInstance().init(config);


DisplayImageOptions options = new DisplayImageOptions.Builder()
    .displayer(new RoundedBitmapDisplayer(50))
    .showStubImage(R.drawable.ic_app)
    .showImageForEmptyUri(R.drawable.camera)
    .showImageOnFail(R.drawable.ic_error).cacheInMemory().cacheOnDisc()
    .build();


public View getView(int position, View convertView, ViewGroup parent) {
    if (convertView == null) {
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.listmessages_row, null);
    }//End if


    ImageView avatar = (ImageView) convertView.findViewById(R.id.ImageView_MessageRow);
    ImageView avatarEmpty = (ImageView) convertView.findViewById(R.id.ImageView_PhotoProfileEmpty);
    final int positionAux = position; 

    if (listItems.get(position).avatar.equals("no_avatar")){
        avatarEmpty.setVisibility(View.VISIBLE);
        avatar.setVisibility(View.GONE);
    }else{
        avatarEmpty.setVisibility(View.GONE);
        avatar.setVisibility(View.VISIBLE);
        imageLoader.displayImage(IMAGES + listItems.get(position).avatar, avatar, options);
    }//End if-else

    return convertView;
}//End getView
4

1 回答 1

15

我回答 myserlf,我修改了 displayImageOtions 的选项,它一直都能完美运行。我只删除了这一行:cacheInMemory()

现在我的显示图像选项是:

options = new DisplayImageOptions.Builder()
        .displayer(new RoundedBitmapDisplayer(50))
        .showStubImage(R.drawable.ic_app)
        .showImageForEmptyUri(R.drawable.camera)
        .showImageOnFail(R.drawable.ic_error)
        .cacheOnDisc()
        .build();
于 2013-10-04T08:00:00.287 回答