我的應用程序有Buttons
當你按Buttons
他們使用文字說話來說話。說話按鈕將不起作用
我Buttons
工作正常,但當我設置id.talk
Button
並給它的語音命令它什麼也沒做。當我點擊它時沒有任何反應。
public void onClick(View v) {
switch (v.getId()) {
// use switch case so each button does a different thing
// accurately(similar to an if statement)
case R.id.btn_speak:
String words1 = speakButton.getText().toString();
// speakwords(xxxx); is the piece of code that actually calls the
// text to speech
speakWords(words1);
Intent voiceIntent = new Intent(
"android.intent.action.RECOGNITIONMENU");
startActivity(voiceIntent);
break;
case R.id.aboutbutton:
String words2 = infoButton.getText().toString();
speakWords(words2);
Intent infoIntent = new Intent("android.intent.action.INFOSCREEN");
startActivity(infoIntent);
break;
case R.id.voicebutton:
speakWords("Speak Now");
startVoiceRecognitionActivity(); // call for voice recognition
// activity
break;
case R.id.talk:
speakWords("This is the main menu.");
break;
}
}
請嘗試通過這個步進,看看什麼是真正回事。嘗試將'Log'輸出放入'case R.id.talk'中,並查看按下'Button'時是否顯示「Log」。讓我們知道結果。 – prolink007 2012-07-26 18:27:55