該應用程序用新文本覆蓋舊文本,但這不是目的。我希望新文本除了保留新文本之外還保留舊文本,比如將舊文本和新文本轉換為字符串然后組合它們?final SpeechRecognizer mSpeechRecognizer = SpeechRecognizer.createSpeechRecognizer(this);final Intent mSpeechRecognizerIntent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);mSpeechRecognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, Locale.getDefault());mSpeechRecognizer.setRecognitionListener(new RecognitionListener() { @Override public void onResults(Bundle bundle) { //getting all the matches ArrayList<String> matches = bundle.getStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION); //displaying the first match if (matches != null) resultText.setText(matches.get(0)); }});
1 回答

紫衣仙女
TA貢獻1839條經驗 獲得超15個贊
所以你想將結果附加到 TextView ?
這很簡單:
resultText.append(matches.get(0));
有空間:
resultText.append(" " + matches.get(0));
其它的辦法:
resultText.setText(resultText.getText() + " " + matches.get(0));
添加回答
舉報
0/150
提交
取消