android - 错误 - 找不到与给定名称匹配的资源(在 'MvxItemTemplate' 处,值为 '@layout/WorkViewItem')

标签 android xamarin xamarin.android mvvmcross

我发布了这个问题,因为 IT 花了我 2 天的时间来解决这个问题。而且我认为其他人也可能会被它困住。因此,在此处提供解决方案可以帮助其他人。

WorkItemSelectionView.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res/Lloyd.Droid"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:padding="10dp">
    <TextView
        android:text="Tasks:"
        android:layout_width="fill_parent"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_height="wrap_content"
        android:textStyle="bold" />
    <Mvx.MvxListView
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        local:MvxBind="ItemsSource WorkItems; ItemClick SelectionCommand"
        local:MvxItemTemplate="@layout/WorkItemView" />
</LinearLayout>

工作项 View .axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:local="http://schemas.android.com/apk/res/CCHQ.Droid"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:textSize="30dp"
        local:MvxBind="Text Name" />
</LinearLayout>

编译失败,错误信息:

No resource found that matches the given name (at 'MvxItemTemplate' with value '@layout/WorkViewItem')

最佳答案

这里的问题是

@layout/WorkItemView

应该是

@layout/workitemview

无论文件名如何,AKA 资源名称都需要全部小写

关于android - 错误 - 找不到与给定名称匹配的资源(在 'MvxItemTemplate' 处,值为 '@layout/WorkViewItem'),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27135361/

相关文章:

java - android - HttpUrlConnection 不起作用

android - 如何将 Lambda 转换为简单的 Java 函数表达式

c# - Xamarin.Forms FlexLayout 将大小调整为最大值

android - 没有名称为 getExternalFilesDirs 的方法 - 三星平板电脑

visual-studio-2010 - 用于 Visual Studio 2010 的 Monodroid "Hello-World"失败

c# - monodroid 慢吗?

使用 ANT 脚本构建 Android NDK

java - 当用户未连接到互联网时写入 firebase 数据

android - 随机 System.ArgumentException : 'jobject' must not be IntPtr. 零

listview - 更改 Android 上的 Xamarin.Forms Listview 中的默认 TextColor