我在 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