1

I have 5 edit text fields in my form, I can able to switch to next field using keyboard next button.

once I visit the last field in the form, when user clicks next it is again going to the top filed, here I want to dismiss the keyboard.

can any one help me how to close it

Praneeth
  • 1,260
  • 18
  • 37

1 Answers1

0

To do this programmatically, you can use InputMethodManager(), as following:

int count = 1;
View view = this.getCurrentFocus();
if(view == R.id.YOUR_FIRST_VIEW_ID && count < 2){
    ++count;
}
else if (view == R.id.YOUR_FIRST_VIEW_ID && count == 2) {  
    InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}

So when you are on your first edit box, 2nd time count = 2, then hide the keyboard.

Kaushal28
  • 5,377
  • 5
  • 41
  • 72