开发者

Android: Create ListView in XML?

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜