2016-06-26 5 views
0

私は問題があります...私はXamarinを通じてAndroid開発を学び始めました。私のappwidget-providerはxmlフォルダでは動作しませんが、レイアウトフォルダで動作します

私はHelloWorldWidgetという最初のウィジェットを作成しようとしています。

私の問題は、私のappwidgetプロバイダのXMLは、XMLフォルダ内に認識されていないされており、私はこのエラーを受けている:私はレイアウトのリソースにファイルをコピーして、に私のリソースパスを変更すると

No resource found that matches the given name (at 'resource' with value '@xml/HelloWorldWidgetProvider'). HelloWidget.Droid C:\Users\paulo\Source\Repos\Pocs\HelloWidget\HelloWidget\HelloWidget.Droid\obj\Debug\android\manifest\AndroidManifest.xml 17 

を@ layout /、すべて正常に動作します。

リソース/ XML/HelloWorldWidgetProvider.xml

<?xml version="1.0" encoding="UTF-8" ?> 
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android" 
    android:minWidth="40dp" 
    android:minHeight="40dp" 
    android:updatePeriodMillis="86400000" 
    android:initialLayout="@layout/HelloWorldWidget" 
    android:resizeMode="horizontal|vertical" 
    android:widgetCategory="home_screen"> 
</appwidget-provider> 

リソース/レイアウト/ HelloWorldWidget.xml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView 
     android:id="@+id/HelloWorldWidgetText" 
     android:text="Hello World!" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" /> 

</LinearLayout> 

HelloWordWidget.cs

[BroadcastReceiver(Label = "@string/HelloWorldWidgetLabel")] 
[IntentFilter(new string[] { "android.appwidget.action.APPWIDGET_UPDATE" })] 
[MetaData("android.appwidget.provider", Resource = "@xml/HelloWorldWidgetProvider")] 
public class HelloWorldWidget : BroadcastReceiver 
{ 
    public override void OnReceive(Context context, Intent intent) 
    { 
     Toast.MakeText(context, "Received intent!", ToastLength.Short).Show(); 
    } 
} 
:ここ

が私のファイルです

手がかりは?常に少しトリッキーです

答えて

1

;)あなたはそれを下ケース

[MetaData("android.appwidget.provider", Resource = "@xml/helloworldwidgetprovider")] 
+0

OMFGを参照してくださいする必要があります!ありがとうございました!!!! :D –

関連する問題