I\'ve searched half a dozen other answers on SO, but haven\'t found one that works. All I\'m trying to do is dismiss the soft keyboard when the user presses the enter butto
Below code works for me.
IN XML:
android:imeOptions="actionDone"
android:inputType="textCapWords"
IN JAVA CLASS:
edit_text.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
// TODO Auto-generated method stub
if ((actionId==EditorInfo.IME_ACTION_DONE ) )
{
//Toast.makeText(getActivity(), "call",45).show();
// hide virtual keyboard
InputMethodManager imm = (InputMethodManager)getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
//or try following:
//InputMethodManager imm = (InputMethodManager)getBaseContext().getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(auto_data.getWindowToken(), 0);
return true;
}
return false;
}
});