我有一个程序,需要通过语音输入比较字符串输入。但是,虽然它显示在结果列表中,但它什么都没有。问题是什么? 示例代码:
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == VOICE_RECOGNITION_REQUEST_CODE && resultCode == RESULT_OK) {
// Fill the list view with the strings the recognizer thought it could have heard
ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
mList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,matches));
for(int i=0;i<matches.size();i++){
if(matches.get(i).equals("添加")){
Toast.makeText(getApplicationContext(), "get", Toast.LENGTH_LONG);
}
}
}
super.onActivityResult(requestCode, resultCode, data);
}
上面的代码没有任何东西,尽管“添加”已经显示在结果列表中。