Android - Place Image In Listview Imageview From Json Api Call
Im new to android and this seems to be overly complicated for no reason at all. I have a simpleadapter adding data to a list view with 5 values. One of which is a URL for an image.
Solution 1:
If you need a quick and easy way to set the image in a View using just the url, then Volley has the solution built in for you.
Replace your ImageView with a com.android.volley.toolbox.NetworkImageView and you can easily set the image with just two lines of code:
NetworkImageView:
<com.android.volley.toolbox.NetworkImageView
android:id="@+id/brandlogo"
android:layout_width="150dp"
android:layout_height="170dp"
android:layout_centerHorizontal="true" />
In your code:
NetworkImageViewlogo= (NetworkImageView)view.findViewById(R.id.brandlogo);
logo.setImageUrl("http://YourURL",mImageLoader);
See the Android documentation.
Solution 2:
You can't directly add image url into imageview. First you have to download that image and then set it in imageview. To download and set image to imageview you can use Image Loader libraries like Glide or Picasso. Here is the link for Glide
And on how to use this library follow the tutorial given in the link.
Hope this will help
Post a Comment for "Android - Place Image In Listview Imageview From Json Api Call"