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!
Use the
android:entriesattribute on yourListViewelement, pointing to a<string-array>resource (typically put inres/values/arrays.xml).