-1

I have few images which are retrieved from my web service.
I want to display these images in grid view in android.
How can i do this??

Thanks,
Sneha

Smitha
  • 6,110
  • 24
  • 90
  • 161

2 Answers2

1

See the following url to create a gridview

How to create grid view

you have to set image inside getView() method

If you have image in the form of bitmap then use

imageview.setImageBitmap(bm);

If you have image in the form of drawable then use

imageview.setImageDrawable(drawable);

If you have image in your resource example if image is present in drawable folder then use

imageview.setImageResource(R.drawable.image);

If you have path of image then use

imageview.setImageURI(Uri.parse("pathofimage));

If you have image in byte array format then you can convert that byte array into Bitmap and use any of the above method.

Thanks Deepak

Sunil Kumar Sahoo
  • 53,011
  • 55
  • 178
  • 243
0

There are different image loader libraries which will help to load these images in ImageView

Inside getView() use:

Picasso library:

Picasso.with(mContext).load("http://url.com/image.jpeg")into(imageView);

or Glide library:

Glide.with(mContext).load("").into(imageView)

Read this article about three image loader library.

https://stackoverflow.com/a/29558169/5056336

Community
  • 1
  • 1