Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android小部件xamarin_Android_Xamarin_Widget - Fatal编程技术网

Android小部件xamarin

Android小部件xamarin,android,xamarin,widget,Android,Xamarin,Widget,我创建了一个简单的小部件,当我试图运行它时,我遇到了这种异常: Parameter name: Type is not derived from a java type.(this, Java.Lang.Class.FromType (typeof (WordWidget)).Name 代码是: [Service] public class UpdateService : Service { public override void OnStart (Intent intent, in

我创建了一个简单的小部件,当我试图运行它时,我遇到了这种异常:

Parameter name: Type is not derived from a java type.(this, Java.Lang.Class.FromType (typeof (WordWidget)).Name
代码是:

[Service]
public class UpdateService : Service
{
    public override void OnStart (Intent intent, int startId)
    {
        RemoteViews updateViews = buildUpdate (this);
        ComponentName thisWidget = new ComponentName (this, Java.Lang.Class.FromType (typeof (WordWidget)).Name);
        AppWidgetManager manager = AppWidgetManager.GetInstance (this);
        manager.UpdateAppWidget (thisWidget, updateViews);
    }

我可以很容易地运行这是非常类似于您的代码。您是否尝试过将自己的代码与Xamarin的示例进行比较?我也可以,但在我的项目中,它给我带来了异常,正如我前面提到的。据我所知,我需要以某种方式实现Java.Lang.Class。您能发布完整的堆栈跟踪吗?谢谢您的回复。我意识到我的WordWidget类没有继承AppWidgetProvider android类。“所以现在它起作用了。”维塔利很高兴知道你解决了你的问题。将你的评论作为公认的答案发表可能是有意义的。这将使其他人的生活更轻松,他们可能也会偶然遇到这个问题。