Android中的简单硬编码ListView

b85*_*411 0 android listview hard-coding

是否可以在Android中执行此类操作?(基本上相当于selectoptionHTML):

<ListView android:layout_height="match_parent"
    android:layout_width="match_parent">
        <ListViewItem>TEST</ListViewItem>
        <ListViewItem>TEST1</ListViewItem>
</ListView>
Run Code Online (Sandbox Code Playgroud)

我试过这个,显然不起作用.我在网上找到的只是有关使用适配器的信息,但由于我有一些硬编码值,我不需要使用适配器 - 我很乐意将它直接放在XML文件中.

这可能吗?

Don*_*pan 5

1]在strings.xml中创建一个String数组

2]在Listview标签内使用以下属性android:entries ="@ array/your_array_name"

做完了!