I am using JSON to retrieve user data and I am also getting the image URL but how can I show the image instead of the URL? Currently it only shows the URL from the image.
Here is the code:
StringBuilder tweetResultBuilder = new StringBuilder();
try {
//get JSONObject from result
JSONObject resultObject = new JSONObject(result);
//get JSONArray contained within the JSONObject retrieved - "results"
JSONArray tweetArray = resultObject.getJSONArray("results");
//loop through each item in the tweet array
for (int t=0; t<tweetArray.length(); t++) {
//each item is a JSONObject
JSONObject tweetObject = tweetArray.getJSONObject(t);
//get the username and text content for each tweet
tweetResultBuilder.append(tweetObject.getString("from_user")+": ");
tweetResultBuilder.append(tweetObject.get("profile_image_url")+"\n");
tweetResultBuilder.append(tweetObject.get("text")+"\n\n");
}
}
You should download and cashe you image first.
Please read this article Displaying Bitmaps Efficiently, and check Sample application
The shorter way to display image from url: