Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 8th, 2012  |  syntax: None  |  size: 0.94 KB  |  hits: 4  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How can I download ListView HTML images asynchronously?
  2. public View getView(final int position, View view, final ViewGroup parent) {
  3.    TextView textView = (TextView) view;
  4.     if (textView == null) {
  5.        textView = new TextView(parent.getContext());
  6.        textView.setPadding(6, 6, 6, 6);
  7.     }
  8.     textView.setText(Html.fromHtml("<img src="" + URLS[position] + ""/>",
  9.        new ImageGetter() {
  10.        @Override public Drawable getDrawable(final String source) {
  11.           ImageView imageView = new ImageView(parent.getContext());
  12.           imageDownloader.download(source, imageView);
  13.           return imageView.getDrawable();
  14.        }
  15.     }, null));
  16.  
  17.     return textView;
  18. }
  19.        
  20. public View getView(int position, View view, ViewGroup parent) {
  21.     if (view == null) {
  22.         view = new ImageView(parent.getContext());
  23.         view.setPadding(6, 6, 6, 6);
  24.     }
  25.  
  26.     imageDownloader.download(URLS[position], (ImageView) view);
  27.  
  28.     return view;
  29. }