我试图检索值微调选择,我用下面的代码从微调器检索选定的项目?
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
Object item = parent.getItemAtPosition(pos);
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
,但我不能使用物品的价值功能之外!我很新到Java请别人帮我..我 努力实现语音识别Android中
public void speakButtonClicked(View v)
{
startVoiceRecognitionActivity();
}
/**
* Fire an intent to start the voice recognition activity.
*/
private void startVoiceRecognitionActivity()
{
Intent intent = new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH);
intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
RecognizerIntent.LANGUAGE_MODEL_FREE_FORM);
intent.putExtra(RecognizerIntent.EXTRA_PROMPT, "Voice recognition Demo...");
startActivityForResult(intent, REQUEST_CODE);
}
/**
* Handle the results from the voice recognition activity.
*/
@Override
protected
void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK)
{
// Populate the spinner with the String values the recognition engine thought it heard
ArrayList<String> matches = data.getStringArrayListExtra(
RecognizerIntent.EXTRA_RESULTS);
final Button button12=(Button)findViewById(R.id.button12);
final Spinner Speech_spinner=(Spinner)findViewById(R.id.spinner3);
Speech_spinner.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,
matches));
Speech_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
Text = parent.getItemAtPosition(pos).toString();
}
public void onNothingSelected(AdapterView<?> parent) {
}
});
button12.setText(Text);
}
super.onActivityResult(requestCode, resultCode, data);
}
没有值在button12
当我用最后它显示无效modifier.i已经使用了一个函数内部的微调在我的主类 – user1186739 2012-03-14 12:23:49
你能告诉我在该方法中你从微调想要的吗? – 2012-03-14 12:24:58
实现谷歌的语音识别在recognizor我project..so输出我想成为spinner..i内已编辑的问题/请chekout功能 – user1186739 2012-03-14 13:09:31