Guest User

Untitled

a guest
Oct 19th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public class DownloadImageTask extends AsyncTask<String, Void, Bitmap> {
  2. ImageView bmImage;
  3.  
  4. public DownloadImageTask(ImageView bmImage) {
  5. this.bmImage = bmImage;
  6. }
  7.  
  8. protected Bitmap doInBackground(String... urls) {
  9. String urldisplay = urls[0];
  10. Bitmap mIcon11 = null;
  11. try {
  12. InputStream in = new java.net.URL(urldisplay).openStream();
  13. mIcon11 = BitmapFactory.decodeStream(in);
  14. } catch (Exception e) {
  15. Log.e("Error", e.getMessage());
  16. e.printStackTrace();
  17. }
  18. return mIcon11;
  19. }
  20.  
  21. protected void onPostExecute(Bitmap result) {
  22. bmImage.setImageBitmap(result);
  23. }}
  24.  
  25. new DownloadImageTask(holder.iconeNoticia).execute(this.main.noticias.get(position).urlImg);
Add Comment
Please, Sign In to add comment