Android ListView custom row layout

倖福魔咒の 提交于 2019-12-24 19:14:25

问题


I need to set a background color and icon image for each item/row in the list view. ArrayAdapter set a single layout to all the items to be added to the list and I tried to catch every item getChildAt() but it fails !!

simply, I need to build a listview like that :

BTW, It will be used inside the navigation drawer, as shown :


回答1:


You need to use "BaseAdapter" for this task, check the link blow, and customize the example according to your need.

http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/

you can also check this

http://www.vogella.com/articles/AndroidListView/article.html




回答2:


You'll need to define your own custom adapter (look here for info on that) and then you'll be able to do custom layouts for individual list view items



来源:https://stackoverflow.com/questions/20741361/android-listview-custom-row-layout

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