我正在使用Universal Image Loader从后端加载图片以在列表中显示用户图像;然而,如果图标多次出现,则Universal Image Loader不会填充所有视图。
我不是使用ListView来完成这个任务,我使用ScrollView并用自定义布局进行填充。
有什么想法可以改进通用图像加载器,以确保所有视图都被正确填充吗?
谢谢你的帮助!
- [用户图像1] - 没有图像
- [用户图像1] - 没有图像
- [用户图像2] - 正常
- [用户图像2] - 没有图像
- [用户图像3] - 正常
- [用户图像1] - 正常
- [用户图像1] - 正常
- [用户图像1] - 没有图像
DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
.cacheInMemory( true )
.cacheOnDisk( true )
.build();
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder( this )
.threadPoolSize( 3 )
.defaultDisplayImageOptions( defaultOptions )
.build();
ImageLoader.getInstance().init( config );
我不是使用ListView来完成这个任务,我使用ScrollView并用自定义布局进行填充。
private View createSmallActivity( LayoutInflater inflater, final Event activity ) {
final View view;
view = inflater.inflate( R.layout.activity_posted_small, null );
...
// The owner's image.
if( activity.ownerImageUrl != null ) {
Loader.loadImage( getActivity(),
activity.ownerImageUrl,
R.drawable.postedactivitysmall_imageprofileempty,
( ImageView ) view.findViewById( R.id.profileImage ) );
}
return view;
}
// Loader.loadImage
// Setting the targetSize, and masking the image with a resource.
public static void loadImage( Context context, String url, int resource, ImageView view ) {
Drawable d = context.getResources().getDrawable( resource );
int h = d.getIntrinsicHeight();
int w = d.getIntrinsicWidth();
ImageSize targetSize = new ImageSize( w, h );
ImageLoader.getInstance().loadImage( url, targetSize, new MaskImageLoader( context, view, resource ) );
}
有什么想法可以改进通用图像加载器,以确保所有视图都被正确填充吗?
谢谢你的帮助!
Adapter
类中getView
函数的代码,其中加载了图片? - Abhishek V