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