如何使用没有适配器的ListView

Coo*_*gos 0 android android-listview

通常情况下,我们使用ListViewBaseAdapter.但是这些天我研究适配器模式.我想知道我们是否可以在ListView没有适配器的情况下使用?例如,我们可以在中编写项目ListView,如下所示:

<ListView>
        <Item/>
        <Item/>
        <Item/>
</ListView>  
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多次,但它不起作用.我可以ListView不用Adapter吗?

Sjd*_*Sjd 5

试试这个..

在string.xml中首先执行此操作..

   <string-array name="Entries">
    <item>Item 1</item>
    <item>Item 2</item>
    <item>Item 3</item>
   </string-array>
Run Code Online (Sandbox Code Playgroud)

然后在xml中的ListView中执行此操作.

    <ListView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:entries="@array/Entries"></ListView>
Run Code Online (Sandbox Code Playgroud)