开发者

Android: ListAdapter populating image (icon) source

开发者 https://www.devze.com 2023-01-02 16:46 出处:网络
I\'m populating a list from the DB, and i have a image field in the DB which contains a URL to a image file.

I'm populating a list from the DB, and i have a image field in the DB which contains a URL to a image file.

ListAdapter adapter=new SimpleCursorAdapter(this,
R.layout.row, constantsCursor,
new String[] {"title", "subtitle", "image"},
new int[] {R.id.value, R.id.title, R.id.icon});

However, the other fields are populated, but the image r开发者_开发技巧emains empty. Why?


  1. most likely you get an exception, and it woulf have been best if you showed that exceptions here.
  2. From my experience with android and SQLight + images you don't get the image but a URL that points to the image and then you need to retrieve the image itself by using getContentResolver().openInputStream() this is how,for example, you retrieve contact's images, you query the contact's details for the image uri and then open the input stream the way i showed you. to do it using the simple cursor adapter, if that's the case here, you also need to implement ViewBinder so when the cursor adapter sees the uri it will know to retrieve the data and put it in the view.
0

精彩评论

暂无评论...
验证码 换一张
取 消