How to load multiple images from url to viewer

I am new to android. I need to load multiple images from URL

to viewpager

usinglazyloading

images do not belong to drawings

These are my urls :

String[] imagUrl={
    "http://img6a.flixcart.com/image/shoe/b/v/g/black-coaster-globalite-10-200x200-imadw577jjh5fsry.jpeg",
    "http://img6a.flixcart.com/image/shoe/b/v/g/black-coaster-globalite-10-200x200-imadw577shaeghnn.jpeg",

};

      

+3


source to share


2 answers


You don't need to do anything using the link http://www.androidhive.info/2012/07/android-loading-image-from-url-http/ .

After the array is created by copying the files ImageLoader.java

, FileCache.java

, MemoryCache.java

and Utils.java

in your application.



    // Imageview to show
    ImageView imageView = new ImageView(context);
    // ImageLoader class instance
    ImageLoader imgLoader = new ImageLoader(getApplicationContext());
     // Loader image - will be shown before loading image
    int loader = R.drawable.loader;
    // whenever you want to load an image from url
    // call DisplayImage function
    // url - image url to load
    // loader - loader image, will be displayed before getting image
    // image - ImageView 
    imgLoader.DisplayImage(imagUrl[position], loader, imageView );

      

+2


source


Also, there is a nice library called: ( picasso

) that you can use.

Here's a tutorial:

http://javatechig.com/android/how-to-use-picasso-library-in-android



And for codes:

//Initialize ImageView
ImageView imageView = (ImageView) findViewById(R.id.imageView);
ImageView imageView = (ImageView) findViewById(R.id.imageView2);

//Loading image from below url into imageView

Picasso.with(this)
   .load("YOUR IMAGE URL HERE")
   .into(imageView);

Picasso.with(this)
       .load("Your second image url")
       .into(imageView2);

      

With the best results, you can do this.

0


source







All Articles