Error in displaying an image in a listview

梦想的初衷 提交于 2020-01-06 15:32:30

问题


I have an image resource ID in an SQLite database and I would like to display this image in a list view. I have created a row template but the default image is displayed in the list. How do I update the image src?

to populate the list view, I use the following code

    ListView listView = (ListView) findViewById(R.id.winnerListView);

    int[] viewColumns = {R.id.winnerPositionView, R.id.winnerIcon, R.id.winnerNameView, R.id.winnerScoreView};

    SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, R.layout.result_row_layout, c, DatabaseHelper.PROJECTION, viewColumns, 0);

    listView.setAdapter(adapter);

Thanks


回答1:


In ordes to do that you must have custom adapter class for list view ,using this adapter class you must set view for each row of listview

Here is some Tutorial 1 , Tutorial 2, Tutorial 3, Tutorial 4 Hope this will help you




回答2:


Here having sample projects how to load image in a list view. Please go through it.

Click here for more details



来源:https://stackoverflow.com/questions/14743369/error-in-displaying-an-image-in-a-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!