Search code examples
androidgridviewimageviewuniversal-image-loader

Load multiple images in ImageView


I have a grid view which shows some images loaded from a server. I use Universal image loader to load the images in the imageView. the problem is it takes time to load those images and I don't want their places to be empty. I want to show an image which is located in the assets of the app and then load the images from server on top of it.
I wanted to ask if you have any solutions to this problem.
Thanks very much


Solution

  • Very generic way to use DisplayImageOptions is as

    DisplayImageOptions displayImageOptions = new DisplayImageOptions.Builder()
                .showImageOnLoading(R.drawable.placeholder_image).showImageForEmptyUri(0)
                .resetViewBeforeLoading(true).cacheInMemory(true).cacheOnDisk(true)
                .imageScaleType(ImageScaleType.IN_SAMPLE_INT).bitmapConfig(Bitmap.Config.RGB_565)
                .delayBeforeLoading(100).displayer(new FadeInBitmapDisplayer(500)).build();
    

    Here showImageOnLoading(R.drawable.placeholder_image) method is used to display a placeholder image until the real image is loaded. R.drawable.placeholder_image is the drawable you want to show as placeholder.