I want to present some choices in my application. Right now I'm doing it with buttons one under another.
What I really want to do is to present them as a list like in "Settings" application. This boils down to creating a list with predefined values/choices. My problem is that I can't figure out how to do it with xml. I can add ListView to xml like this:
<ListView android:id="@+id/ListView01" android:layout_width="wrap_content" android:layout_height="wrap_content"></ListView>
But how do I add entries to that? All examples I've found do it programatically - through cursor adapters or array adapters.
How do I create a list of textViews using XML only n Android? Does anyone know how it's done in "Settings" application and alike?
Thanks!
But how do I add entries to that? All examples I've found do it programatically - through cursor adapters or array adapters.
Use the android:entries
attribute on your ListView
element, pointing to a <string-array>
resource (typically put in res/values/arrays.xml
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With