Search code examples
androidimagelistviewuniversal-image-loader

Universal image Loader : Open actual size image on click of an imageview inside listview


I am using Universal image Loader to bind images to ImageView inside my listview. These images are being fetched from online url at time of binding asynchronously. Now i want to open the actual size image on click of ImageView. Do i have to cache the images when binding or can i use imageView source to call intent that will handle displaying the Image. I have the below code that opens any image on the device :

Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
Uri imgUri = Uri.parse("file://" + yourfilepath);
intent.setDataAndType(imgUri, "image/*");
startActivity(intent);

In what way i can simply display the image loaded using Universal image Loader in user's default image viewer app on click event of listview.


Solution

  • If you use DisplayImageOptions of the universal image loader, your images will be cached. So that you can use the url of the image to load by using displayimage of the universal loader

    ImageLoader imageLoader = ImageLoader.getInstance();
    DisplayImageOptions options;
    imageLoader.init(ImageLoaderConfiguration.createDefault(context));
            options = new DisplayImageOptions.Builder()
                    .showImageOnLoading(R.drawable.img_default)
                    .showImageForEmptyUri(R.drawable.img_default)
                    .showImageOnFail(R.drawable.img_default).cacheInMemory(true)
                    .cacheOnDisk(true).considerExifParams(true).build();
    imageLoader.displayImage(your_url, your_imageview, options);
    

    You use your own activity with an image view to show the image. You can send the url through extras and load the url in the image view using displaymage().