5

我正在尝试使用 Android Studio 中的“工具”命名空间功能。出于设计目的,我正在尝试ListView使用虚拟列表项填充。这里的链接说tools:listitem="@android:layout/<filename>"应该做。

但由于某种原因,Android Studio 不断显示Layout android:<filename> does not exist.我正在尝试为其寻找解决方案,因此我不必一次又一次地使用虚拟值运行我的应用程序进行测试。

我可能忽略了一些非常愚蠢的事情,所以请原谅我。这是我现在所拥有的:

<ListView
    android:id="@+id/controllerProfiles"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="20dp"
    tools:listitem="@android:layout/profiles_list_item"/>

我在任何建议或替代方案profiles_list_item.xml下有一个文件?res/layout.

4

2 回答 2

7

您应该更改以下行:

tools:listitem="@android:layout/profiles_list_item"

对此:

tools:listitem="@layout/profiles_list_item"

@android你说你想使用来自android资源的布局,但你的布局在你自己的项目文件中。

于 2015-06-16T21:20:45.867 回答
4

tools:listitem 不适用于 Android Studio 2.2 中的 ListViews。这是一个已知的错误。我已经在 Android Studio 2.3 beta 1 中对此进行了测试,并在此处修复。

您也可以从 ListView 移动到 RecyclerView,因为 RecyclerViews 不会出现此错误。

于 2016-12-16T16:31:24.517 回答