c# - 关于 xamarin 的通知。 Android.Resource.Drawable.SymActionEmail 错误

标签 c# android xamarin notifications xamarin.android

嗨,我是一名理工学院的学生。我对 xamarin 完全陌生,因此我将不胜感激。

所以我的问题是我最近关注了这个 tutorial关于如何在 xamarin android 上创建通知并在 MyBroadcastReceiver.cs 中遇到此问题。它表示在创建通知注释下 resource.drawable 不包含“SymActionEmail”的定义。任何解决此问题的帮助将不胜感激。

最佳答案

我认为问题在于这个类所在的命名空间并且带有 .Android 后缀。这意味着 Android.Resource.Drawable 实际上并不引用 Xamarin Android 自己的 Resource.Drawable 类,而是引用您的项目特定的 Resource.Drawable类(class)。为了克服这个问题,您需要重命名此类的命名空间,使其不以 .Android 结尾,或者为默认的 Android 命名空间添加 using 别名:

//add this to the using statements in this file
using Sys = Android;
...
//now use the following in your code 
//to use Xamarin Android's built-in Resource.Drawable class
var notification = new Notification( Sys.Resource.Drawable.SymActionEmail, title );

关于c# - 关于 xamarin 的通知。 Android.Resource.Drawable.SymActionEmail 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38341625/

相关文章:

c# - 从 Google 选择并下载随机图片

c# - 使用 kestrel 在同一端口(如虚拟应用程序)上增加监听器

c# - C# 结构中的引用类型

c# - 如何在 C# 中将 cookie 过期时间设置为 session

Android:如何使用动态 TextView 为不同的屏幕尺寸设置不同的文本尺寸?

c# - Xamarin 表单更新 listView itemSsource

java - 我在 Android Studio 中的代码会发生什么情况?

java - android java socket.io 不会向 nodejs 服务器发出任何事件

c# - 在 xamarin iOS 中 - 在 UITableViewCell 中获取 [indexPath.Row],使用按钮单击事件

android - 将数据从一个 xamarin.android 应用程序发送到另一个 xamarin.forms 应用程序