c# - 资源不包含 Id 的定义 - c# Xamarin Visual Studio

标签 c# android visual-studio xamarin resources

我正在尝试通过以下命令从 Strings.xml 获取 Array:

        string[] menuItems = Resources.GetStringArray(Resource.Array.menu);

但是我收到以下错误:

       'Resource' does not contain a definition for 'Array'

我也收到了以下行的相同类型的错误:

    TextView webAddress = view.FindViewById<TextView>(Resource.Id.txtTourUrl);

'Resource' does not contain a definition for 'Id'

我猜它与 Resource.Designer.cs 文件有关,但我不确定如何修复它...

更新 1:

这些是修复它的选项:

enter image description here

提前致谢。

最佳答案

对于那些可能有同样问题的人......

它没有重建的原因是因为我的 Main.axml 文件中有一个错误,其中对象/小部件 ID 是:android:id="@android:id/list" 注意ID 名称前的空格...

这会导致重建错误,无法为 Resources 中的 Resource.Id 生成类。

只需删除任何可能导致错误的空格或任何符号,然后再次重建解决方案

关于c# - 资源不包含 Id 的定义 - c# Xamarin Visual Studio,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47136262/

相关文章:

c# - C#中整数的初始化和声明背后的内存管理概念

c# - 使用 C# 应用程序安装 SQL Server Express

c++ - 如何修复 "not recognized as an internal or external command"问题

c# - GUITexture 已被弃用,那么我应该使用什么来代替它呢?

c# - Powershell运行空间写入 protected 变量(不可替换)

c# - 未为项目设置 OutputPath 属性

c# - 在智能感知中找到但在编译时找不到的扩展

Android 从第二个线程访问 UI

android - 使用 halninja ffmpeg 在 Android 中连接 mp4 文件

android - 将图片粘贴到可绘制文件夹中时没有出现选项?