I have an AutoCompleteTextView, it gives a list of suggestions like it should, when you type something into the TextView. However, when you select the suggestion, you still have to hit Enter to not only remove the keyboard from the screen but to submit the suggestion that you chose. I'm trying to remove this extra step of hitting Enter because users aren't making the connection in my application that they have to hit enter key after they select the suggestion in the TextView. Any suggestions/help?
Here is what I've got that was suggested but it doesn't seem to be working.
element_image = (ImageView) findViewById(R.id.element_bullet);
//Get the string array of the radionuclide names that will auto complete.
radionuclideNames = getResources().getStringArray(R.array.radionuclide_names);
//Get a reference to the AutoCompleteTextView in the layout.
radionuclideTextView = (AutoCompleteTextView) findViewById(R.id.radionuclide_autocomplete);
//Create the adapter and set it to the AutoCompleteTextView.
ArrayAdapter<String> adapter =
new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, radionuclideNames);
//Apply the adapter to the AutoCompleteTextView.
radionuclideTextView.setAdapter(adapter);
//Listen for when enter is pressed.
radionuclideTextView.setOnItemSelectedListener(new OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
switch(parent.getId())
{
case R.id.radionuclide_autocomplete:
element_image.setImageResource(R.drawable.selectedbulletstate);
break;
}
}
public void onNothingSelected(AdapterView<?> parent) {
//TODO:
}
});