1

Is it possible to do something like this in Android? (basically the equivalent of select and option in HTML):

<ListView android:layout_height="match_parent"
    android:layout_width="match_parent">
        <ListViewItem>TEST</ListViewItem>
        <ListViewItem>TEST1</ListViewItem>
</ListView>

I have tried this, it obviously doesn't work. All I can find online is information about using adapters, but as I have some hard coded values I don't need to use an adapter - I'm happy to put it directly in the XML file.

Is this possible?

b85411
  • 9,420
  • 15
  • 65
  • 119

2 Answers2

7

1 ] Create a String array in strings.xml

2 ] Use the following attribute inside Listview tag android:entries="@array/your_array_name"

Done !

Don Chakkappan
  • 7,397
  • 5
  • 44
  • 59
  • Complete demonstration can be found here http://theopentutorials.com/tutorials/android/listview/android-creating-and-populating-listview-items-in-xml/ – Don Chakkappan Nov 18 '14 at 07:17
1

No It is not possible in android but used android:entries properties to load list item using String resource array.

Haresh Chhelana
  • 24,720
  • 5
  • 57
  • 67