>我正在尝试使用Android Studio中的"tools"命名空间功能。出于设计目的,我正在尝试使用虚拟列表项填充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.
有什么建议或替代方案吗?
您应该更改以下行:
tools:listitem="@android:layout/profiles_list_item"
对此:
tools:listitem="@layout/profiles_list_item"
对于@android
,您说要使用 Android 资源中的布局,但您的布局在您自己的项目文件中。
tools:listitem 不适用于 Android Studio 2.2 中的 ListViews。这是一个已知的错误。我已经在Android Studio 2.3 beta 1中对此进行了测试,并在此处修复。
您也可以从 ListView 移动到 RecyclerView,因为 RecyclerView 中不会出现此错误。