我想在 Android ListView 中获取特定项目。ListView 应该从语音识别器函数中填充。如果不单击自动,我怎么能做到这一点?我尝试了一些东西,但没有工作。任何帮助将不胜感激!
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
// Populate the wordsList with the String values the recognition engine thought it heard
ArrayList<String> matches = data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
wordsList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
matches));
String info = wordsList.getItemAtPosition(0).toString();
if(info.indexOf("Hello")>0){
Toast.makeText(getBaseContext(),"OK", Toast.LENGTH_LONG).show();
}
}
super.onActivityResult(requestCode, resultCode, data);
}