HOW TO HIDE KEYBOARD ON OUTSIDE TAP FOR EDITTEXT, IN ANDROID.

Ankita Pandey

Total Post:183

Points:1285
Posted by  Ankita Pandey
 1786  View(s)
Ratings:
Rate this:
How to hide keyboard on outside tap for  edittext, in android.?
  1. Jayden Bell

    Post:110

    Points:774
    Re: How to hide keyboard on outside tap for edittext, in android.

    On your activity you have need to add touch method like this :


          @Override
          public boolean onTouchEvent(MotionEvent event) {
                // TODO Auto-generated method stub
     
                InputMethodManager inputManager = (InputMethodManager) getApplicationContext()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
     
                inputManager.hideSoftInputFromWindow(MainActivity.this
                            .getCurrentFocus().getWindowToken(),
     
                InputMethodManager.HIDE_NOT_ALWAYS);
     
                return super.onTouchEvent(event);
          } 

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!