I have an image view in my android application. I want to set the picture dynamically from a link.

Example:
The user has an id number of 0920305

The image from http://teachers.usls.edu.ph/student_pics/0920305 will appear on the image view.

Recommended Answers

All 2 Replies

Read it once, store it in sd-card with timestamp in db or sharedpreferences and next time just check if user profile last change timestamp is same as the one you have on record. You save precious download time and less content to download

Fetching data (in this case image) from web is a blocking operation and Android doesn't allow it to be done on UI (or Activity) Thread. You need to create a new thread for it.

class AsyncTask provides a in-built support for creating a thread by itself, handling it and allowing to fetch data.

In its "doInBackGround" method do the necessary work to fetch data.
In the "postExecute" method you can set the image.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.