Simple hard coded ListView in Android

3.4k views Asked by At

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?

2

There are 2 answers

1
Don Chakkappan On BEST ANSWER

1 ] Create a String array in strings.xml

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

Done !

0
Haresh Chhelana On

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