简体   繁体   中英

How can you display an image with ListAdapter in a listview?

I want to be able to display images within a listview using ListAdapter.

Currently below I'm passing strings called TAG_COUNTRY , they are image file names for example ireland.png, usa.png for example.

The image string file names appear in my listview in a column, but i need to actually show the images not the file name. Im confused whats the best approach to take here.

ListAdapter adapter = new SimpleAdapter(getActivity(), inboxList, R.layout.pga_list_item,
                        new String[] { TAG_ID, TAG_COUNTRY, TAG_FROM, TAG_DATE, TAG_EMAIL, TAG_SUBJECT },
                        new int[] { R.id.from, R.id.pic, R.id.subject, R.id.date, R.id.mail, R.id.roundscore }) {

You'll have use a custom ArrayAdapter or BaseAdapter . Here is a good tutorial.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM