Images not loading from assets folder using Universal Image Loader

≡放荡痞女 提交于 2019-12-20 02:06:15

问题


I do exactly what this guy suggests which is exactly the same as the creator of the Universal Image Loader, but I still get this error:

URI = assets://NMF0002_007.jpg
resolveUri failed on bad bitmap uri: NMF0002_007.jpg

What should I look for to ensure that the images are recognised?

I use it like this:

//get the file name
String fileName = cursor.getString(cursor.getColumnIndexOrThrow(DatabaseHelper.FIELD_RESOURCE));
String imageUri = "assets://";
Log.d(TAG, "URI = " + imageUri + fileName);
ImageLoader.getInstance().displayImage(imageUri+fileName, holder.iv_details_resource);

This is my configuration:

//Get the imageloader.
ImageLoader imageLoader = ImageLoader.getInstance();

//Create image options.
DisplayImageOptions options = new DisplayImageOptions.Builder()
    .cacheOnDisc() 
    .imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2) 
    .bitmapConfig(Bitmap.Config.RGB_565)
    .build();

//Create a config with those options.
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(getApplicationContext())
    .defaultDisplayImageOptions(options)
    .discCacheExtraOptions(480, 800, CompressFormat.JPEG, 75)
    .build();

//Initialise the imageloader.
imageLoader.init(config);

What am I doing wrong or missing?


回答1:


Solution - I was looking for .jpg and my file extension was .JPG

If NOSTRA can post some clever things to be on the lookout for I'll mark your answer as an official answer to my silliness.



来源:https://stackoverflow.com/questions/18034576/images-not-loading-from-assets-folder-using-universal-image-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!