[英]TextToSpeech(this, this); does not work
Thanks for seeing my question. 感谢您看到我的问题。 My problem is that TextToSpeech(this, this);
我的问题是TextToSpeech(this, this);
does not work. 不起作用。
I have initiated it in my code like this. 我已经在这样的代码中启动了它。
private TextToSpeech txt2Speech;
then inside onCreate()
然后在onCreate()
txt2Speech = new TextToSpeech(this, this);
And the end of my code I have declared an onInitListener()
like this: 在代码的结尾,我声明了一个onInitListener()
如下所示:
public void onInit(int status) {
// TODO Auto-generated method stub
}
Yet Android Studio shows an error on this line - 然而,Android Studio在此行显示错误-
txt2Speech = new TextToSpeech(this, this);
Saying that 这样说
required type
onInitListener()
does not match the type of myclass
which isMainActivity.java
所需的类型onInitListener()
与我的class
的类型为MainActivity.java
不匹配
What Have I Done Wrong? 我做错了什么? Pls Help me. 请帮助我。 Thank you in Advance 先感谢您
Make sure your Activity implements TextToSpeech.OnInitListener
, something like this 确保您的Activity实现了TextToSpeech.OnInitListener
,类似这样
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener
from there you are free to override the onInit
method 从那里,您可以随意重写onInit
方法
@Override
public void onInit(int status) {
// your code
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.