Thanks for seeing my question. My problem is that TextToSpeech(this, this);
does not work.
I have initiated it in my code like this.
private TextToSpeech txt2Speech;
then inside onCreate()
txt2Speech = new TextToSpeech(this, this);
And the end of my code I have declared an onInitListener()
like this:
public void onInit(int status) {
// TODO Auto-generated method stub
}
Yet Android Studio shows an error on this line -
txt2Speech = new TextToSpeech(this, this);
Saying that
required type
onInitListener()
does not match the type of myclass
which isMainActivity.java
What Have I Done Wrong? Pls Help me. Thank you in Advance
Make sure your Activity implements TextToSpeech.OnInitListener
, something like this
public class MainActivity extends AppCompatActivity implements TextToSpeech.OnInitListener
from there you are free to override the onInit
method
@Override
public void onInit(int status) {
// your code
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.