演讲在我的真实设备上运行良好。
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Android.Speech.Tts;
namespace App7
{
[Activity(Label = "App7", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity, TextToSpeech.IOnInitListener
{
public TextToSpeech SpeechText
{
get;
set;
}
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
// create text to speech object to use synthesize and speak functions.
// first parameter: context
// second parameter: object implemeting TextToSpeech.IOnInitListener
this.SpeechText = new TextToSpeech(this, this);
Button testButton = FindViewById<Button>(Resource.Id.button1);
testButton.Click += delegate
{
this.SpeechText.Speak("Hello World, You shall not pass", QueueMode.Flush, null);
};
// Get our button from the layout resource,
// and attach an event to it
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
}
public void OnInit(OperationResult status)
{
// here you can setup language settings
if (status.Equals(OperationResult.Success))
Toast.MakeText(this, "Text To Speech Succeed!", ToastLength.Long).Show();
else
Toast.MakeText(this, "Text To Speech Fail", ToastLength.Long).Show();
}
}
}
警告就在这一行:
this.SpeechText.Speak("Hello World, You shall not pass", QueueMode.Flush, null);
在此行下方有一条绿线,警告信息为:
警告1&#39; Android.Speech.Tts.TextToSpeech.Speak(字符串,Android.Speech.Tts.QueueMode,System.Collections.Generic.IDictionary)&#39;已过时:&#39;已弃用&#39;
试图谷歌没找到任何东西。 我可以忽略它,但我想知道它是什么意思?我该如何解决?