首页 > 解决方案 > 错误 CS0117 Resource.Layout 不包含选项卡栏和工具栏 xamarin 的定义

问题描述

我使用将现有项目添加到我的项目中添加了另一个登录源代码项目,并且在清理解决方案和重建后出现此错误 在此处输入图像描述

我将 tabbar 重命名为 tabbar2 并将工具栏和 tabbar 从现有重命名为 toolbar1 和 tabbar1

标签: xamarin.androidvisual-studio-2017

解决方案


在我的情况下,为了解决这个问题,我不得不重命名:

layout/toolbar.xml

layout/Toolbar.xml

我从

android.support.v7.widget.Toolbar

androidx.appcompat.widget.Toolbar:

从:

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways" />

<androidx.appcompat.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="?attr/actionBarSize"
    android:minHeight="?attr/actionBarSize"
    android:background="?attr/colorPrimary"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
    app:layout_scrollFlags="scroll|enterAlways" />

这导致编译时出现以下错误:

Error   CS0117  'Resource.Layout' does not contain a definition for 'Toolbar'

从 toobar.xml 重命名为 Toolbar.xml 解决了这个问题。


推荐阅读