Android Image Loading from a String URL
Learn how to load web images into your Android application with just a URL string.
Occasionally, adding images to your android application is simple and straightforward, and all you have to do is place the image in the drawable folder and set the ImageView source (“src”) property in your layout xml file to the correct path.
Things get a bit trickier when you need to pull the image from a URL, often just provided as a string variable. For example, let’s say you are building a news app that pulls current headlines from a news API. Once you parse the JSON data in your app, you will have a string variable with the URL to the image. You may, at this point, be asking yourself, how can you use that string variable to pull the image from the URL and add it to your app? If so you’ve come to the right place, read on to find out how.
Two Paths, One Goal (with a Clear Winner)
I’m sure there are multiple ways to accomplish this task of loading images into your android app from a URL, but I am going to cover two that have worked for me. The first is a do-it-yourself…