I\'m a newbie programmer an I\'m making an android program that displays an image on ImageView from a given url. My problem is how do you use this on the AsyncTask?
Thes
Try this code, make your drawable variable global and change your satellite function like this:
private void satellite() {
// TODO Auto-generated method stub
ImageView imgView =(ImageView)findViewById(R.id.satellite);
new yourTask().execute();
}
then create asyncTask class like this:
private class yourTask extends AsyncTask {
@Override
protected void onPreExecute() {
super.onPreExecute();
//show a progress bar
}
@Override
protected String doInBackground(Integer... params) {
drawable = LoadImageFromWeb("http://www.pagasa.dost.gov.ph/wb/sat_images/satellite.gif");
return 0;
}
@Override
protected void onPostExecute(Integer result) {
super.onPostExecute(result);
imgView.setImageDrawable(drawable);
}
}