Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/database/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android-使用UniversalImageLoader将位图加载到数组中_Android_Arraylist_Bitmap_Universal Image Loader - Fatal编程技术网

android-使用UniversalImageLoader将位图加载到数组中

android-使用UniversalImageLoader将位图加载到数组中,android,arraylist,bitmap,universal-image-loader,Android,Arraylist,Bitmap,Universal Image Loader,我试图用位图填充arraylist,下面是我的代码: ImageLoader imageLoader = ImageLoader.getInstance(); ArrayList<Bitmap> imgArray = new ArrayList<>(); for (int num=0;num<4;num++) { imgArray.add(num,imageLoader.loadImageSync("http://example.co

我试图用位图填充arraylist,下面是我的代码:

ImageLoader imageLoader = ImageLoader.getInstance();
    ArrayList<Bitmap> imgArray = new ArrayList<>();
    for (int num=0;num<4;num++) {
        imgArray.add(num,imageLoader.loadImageSync("http://example.com/sample.jpg"));
    }
ImageLoader ImageLoader=ImageLoader.getInstance();
ArrayList imgArray=新的ArrayList();
对于(int num=0;num配置:

File cacheDir = StorageUtils.getOwnCacheDirectory(
                getApplicationContext(),
                "/sdcard/Android/data/random_folder_name_for_cache");

        DisplayImageOptions options = new DisplayImageOptions.Builder()
                .cacheInMemory(true).cacheOnDisc(true).build();

        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(
                getApplicationContext()).defaultDisplayImageOptions(options)
                .discCache(new FileCountLimitedDiscCache(cacheDir, 100))
                .build();

        ImageLoader.getInstance().init(config);


final ArrayList<Bitmap> imgArray = new ArrayList<>(); // this should be a public array outside of the method scope. a member of the activity
for (int num=0;num<4;num++) {
    ImageLoader imageLoader = ImageLoader.getInstance(); 
    int final constNum = num;
    imageLoader.loadImage("http://example.com/sample.jpg", new SimpleImageLoadingListener() 
    {
        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) 
        {
           imgArray.add(constNum, loadedImage);
        }
    });        
}
File cacheDir=StorageUtils.getOwnCacheDirectory(
getApplicationContext(),
“/sdcard/Android/data/random_folder_name_for_cache”);
DisplayImageOptions=new DisplayImageOptions.Builder()
.cacheInMemory(true).cacheOnDisc(true).build();
ImageLoaderConfiguration配置=新建ImageLoaderConfiguration.Builder(
getApplicationContext()).defaultDisplayImageOptions(选项)
.discCache(新的FileCountLimitedDiscCache(cacheDir,100))
.build();
ImageLoader.getInstance().init(配置);
final ArrayList imgArray=new ArrayList();//这应该是方法范围之外的公共数组。活动的成员

对于(int num=0;numid),初始化ImageLoader?(
ImageLoader.getInstance().init();
)无法写入“CONFIG”这样。它会导致Bitmap.Config,但在它之后仍然不确定如何初始化配置?给我一个例子plz@MarcoBatista你能帮我初始化配置吗?很抱歉我离开了一天,但我看到hasan83已经指向了正确的方向:)评论不适用于长时间的讨论;此对话已结束。