Code example for Spinner

Methods: getSelectedItem, getSelectedItemPosition

0
		// Given an hint to the recognizer about what the user is going to say 
		intent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL,
				RecognizerIntent.LANGUAGE_MODEL_WEB_SEARCH);
 
		// If number of Matches is not selected then return show toast message 
		if (msTextMatches.getSelectedItemPosition() == AdapterView.INVALID_POSITION) {
			Toast.makeText(this, "Please select No. of Matches from spinner",
					Toast.LENGTH_SHORT).show();
			return; 
		} 
 
		int noOfMatches = Integer.parseInt(msTextMatches.getSelectedItem()
				.toString());
		// Specify how many results you want to receive. The results will be 
		// sorted where the first result is the one with higher confidence. 
 
		intent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, noOfMatches);
 
		startActivityForResult(intent, VOICE_RECOGNITION_REQUEST_CODE);
	} 
Experience pair programming with AI  Get Codota for Java