android - 工具命名空间android listitem

标签 android listview android-tools-namespace

我正在尝试使用 Android Studio 中的“工具”命名空间功能。 我正在尝试填充 ListView带有虚拟列表项,用于设计目的。链接heretools: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.xmlres/layout. 下有什么建议或替代方案吗?

最佳答案

您应该更改以下行:

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

为此:

tools:listitem="@layout/profiles_list_item"

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

关于android - 工具命名空间android listitem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30877530/

相关文章:

Android - ListView 不显示最后一项

android - xmlns :tools in Android XML layout?是什么意思

android - 如何在 Android Studio 的 recyclerview 预览中指定列表项计数?

android - 使用游标避免 ANR

Android - Viewpager 和 fragment ,方法不起作用

android - 使用 Sqlite 查询从特定月份选择一组值

java - 如何循环浏览 Android RecyclerView 中的项目?

java - Android:检查一个复选框会检查同一行中的所有复选框

android - 使用自定义适配器时,ListView 不会使用主题设置样式

android - 用于在设计时在 ViewPager 中显示布局的工具命名空间属性