I want to create a list view with l开发者_如何学Pythonimited set of items that isn't really going to change.
Each row is going to have an image on the left and text on the right. (Just like in the Settings app)
Can I populate that in XML (i.e. avoid writing code) ?
I found the answer here: Android - creating listview entirely from xml
"You can use the android:entries
attribute on your ListView
element, pointing to a <string-array>
resource (typically put in res/values/arrays.xml
)."
here is the best example for your question. Custom list view
Use ListView tag & specify reqd attr to it. Then take one layout which will hold all the listview in it.Take another layout which will hold image set it's gravity to left. Take diff layout which will hold text set it's gravity to right & put all these in layout 1
精彩评论