问题
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