2012-02-05 13 views
0

私はこのコードを持っている:Cで#アンドロイドのモノでResource.idが存在しない理由は?

using System; 
using Android.App; 
using Android.Content; 
using Android.Runtime; 
using Android.Views; 
using Android.Widget; 
using Android.OS; 
using Android.Speech.Tts; 
using System.Collections.Generic; 
namespace SayItAndroid{ [Activity (Label = "SayItAndroid", MainLauncher = true)] 
    public class Activity1 : Activity, TextToSpeech.IOnInitListener 
{ 
    int count = 1; 
    TextToSpeech mTts; 
    public void OnInit (int status) 
    { 
     Console.WriteLine ("Listening to text to speech"); 
    } 
    protected override void OnCreate (Bundle bundle) 
    { 
     base.OnCreate (bundle);// Set our view from the "main" layout resource 
     SetContentView (Resource.Layout.Main); 
     Intent checkIntent = new Intent(); 
     checkIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData); 
     StartActivityForResult(checkIntent, 100);   // Get our button from the layout resource,   // and attach an event to it    
     Button button = FindViewById<Button> (Resource.Id.myButton); 
     button.Click += delegate 
     { 
      string myText1 = "Did you sleep well?"; 
      string myText2 = "I hope so, because it's time to wake up."; 
      mTts.Speak(myText1, QueueMode.Add, new Dictionary<string, string>()); 
      mTts.Speak(myText2, QueueMode.Flush, new Dictionary<string, string>()); 
     }; 
    } 
    protected override void OnActivityResult (int requestCode, Result resultCode, Intent data) 
    { 
     base.OnActivityResult (requestCode, resultCode, data); 
     if(requestCode == 100) 
     { 
      mTts = new TextToSpeech(this, this); 
     } 
    } 
}} 

しかし、私は、リソースの下に赤い線のエラーを取得し、リソースイムを持つ2つの場所での:名「リソース」1

エラーは、現在のコンテキスト

には存在しません。

どうすれば解決できますか?

ありがとうございました。

答えて

7

リソースが参照されているファイルと同じ名前空間にないため、リソースが見つからない理由は9回です。

としては、Xamarinによってon this pageを述べて、プロジェクトの既定の名前空間は、あなたのクラスは、物事が壊れ、別の名前空間に存在する場合。

で生成されたリソースのクラスファイルを格納するために使用されます。

あなたのために物事をクリアする希望。

関連する問題