1

I have a problem with my custom view that contains an edittext and a spinner. I have added a "next"-button using IMEoptions. Depending on the spinner, the edittext keyboard should contain either a "next" or a "done" key.

At the moment I solve this using:

@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
    final Object item = adapterView.getItemAtPosition(position);
    if (item.equals(getString(STRING1))) {
    edittext.setImeOptions(EditOptions.IME_OPTIONS_NEXT);
    } else if(item.equals(getString(STRING2)){
    edittext.setImeOptions(EditOptions.IME_OPTIONS_ACTION_DONE);
    }
    edittext.setText(edittext.getText());
     //This updates the edittext but is very much an ugly hack. 
     //Is there another way to update this? invalidate() and forceLayout() 
     //does not do the trick
}
Supahfly
  • 819
  • 6
  • 13

1 Answers1

0

Alternate solution.

edittext.setInputType(InputType.TYPE_CLASS_TEXT);

As described here: change the keyboard layout after a button click

Community
  • 1
  • 1
mindriot
  • 14,149
  • 4
  • 29
  • 40