I have 7 edittext boxes in my xml. I'm using the OnFocusChangeListener to read the value from edittext and i'm using that value for my calculation.I want to make my edittext to lose its focus when i click on the done button in the soft keyboard.so that i can get the value in the edittext.
setOnClickListener(saveButtonListener); private OnClickListener saveButtonListener = new OnClickListener() { @Override public void onClick(View v) { Text1. clearFocus(); Text2. clearFocus(); findViewById(R. id.
First you need to set the android:imeOptions attribute equal to actionDone for your target EditText as seen below. That will change your 'RETURN' button in your EditText's soft keyboard to a 'DONE' button.
Call clearFocus
method of EditText
to lose focus when done button is clicked from soft-keyboard. do it as:
editText.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if(actionId==EditorInfo.IME_ACTION_DONE){ //Clear focus here from edittext editText.clearFocus(); } return false; } });
and also add android:imeOptions="actionDone"
in edittext xml
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With