0

My cursor gets 3 columns of data from sqlite, 1st column is recipe name, 2nd column in recipe author and 3rd column is the url for the recipe's image. here's a portion of my code

private static final String fields[] = { "recipeID", "recipeName", "thumbnail"};
Cursor mCursor = dbAdapter.getAllTitles(); //get all titles returns the recipe name, author and thumbs
startManagingCursor(mCursor);
dataSource = new SimpleCursorAdapter(this, R.layout.recipelist, mCursor, fields,    
                  new int[] { R.id.recipeAuthor, R.id.recipeName, R.id.recipeThumb });
setListAdapter(dataSource);

Obviously instead of displaying the recipe image, the code above just displays the url for the recipe image at R.id.recipeThumb. How can I make it display pictures from the internet instead?

imin
  • 4,504
  • 13
  • 56
  • 103

2 Answers2

0

The post right below the answer in this discussion might be of use to you:

Lazy load of images in ListView

Community
  • 1
  • 1
phil917
  • 113
  • 1
  • 6
  • actually i've been looking at the lazylist post too before, but haven't got the time to modify it to suit my problem.. but I guess I should spend more time looking at it then – imin Jan 20 '12 at 09:02
0

You need a CustomAdapter and override the getView() method. In the getView() method based on the Url you create a ImageView.

getView(...) {
   //First Create a Drawable from the InputStream of the Url 
   //store this drawable locally so that you don't have to fetch it again 
   Drawable imgDrawable = Drawable.createFromStream(inputStream,"");
   //set this in the imageView
   imgView.setImageDrawable(imgDrawable);

   //set this imgView in the contentview and return

}
Rajdeep Dua
  • 11,190
  • 2
  • 32
  • 22