10

I want to create a list view with limited 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) ?

3 Answers 3

13

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)."

Sign up to request clarification or add additional context in comments.

Comments

2

here is the best example for your question. Custom list view

4 Comments

Thanks, I have gone through this before. Actually, I do not want to make it all that complicated, thats why I wanted to know if it could be done in XML.
hey this is not complicated. just try that its a best way to do that.
This isn't really an answer to his question, it is just way of doing something similar. I am also curious if there is a way to define listview content in the xml file.
@Treebranch I found a way. Check my answer.
1

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

1 Comment

i have tried the same with table layout & scrollview it works like listview

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.