2012-01-20 7 views
0

カーソルはsqliteから3列のデータを取得し、1列目はレシピ名、2列目はレシピ作成者、3列目はレシピ画像のURLです。ここに私のコードの一部listviewインターネットからの画像とsqliteからのデータを表示

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); 

明らかに代わりのレシピ画像を表示するのです、ちょうど上記のコードはR.id.recipeThumbのレシピ画像のURLが表示されます。代わりにインターネットから写真を表示するにはどうすればいいですか?

答えて

0

右この議論で答え以下のポストはあなたに使用であるかもしれない:

Lazy load of images in ListView

+0

実際に私も前にlazylistポストを見てきたが、私の問題を合わせて、それを修正するための時間を持っていない..しかし、私はそれを見て多くの時間を費やす必要がありますね – imin

0

あなたはCustomAdapterを必要とgetViewメソッド()メソッドをオーバーライドします。 URLに基​​づくgetView()メソッドでは、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 

} 
関連する問題