Home > DeveloperSection > Forums > How to hide keyboard on outside tap for edittext, in android.
Ankita Pandey
Ankita Pandey

Total Post:183

Points:1285
Posted on    February-27-2015 3:58 AM

 Android Android  Android Controls 
Ratings:


 1 Reply(s)
 1115  View(s)
Rate this:
How to hide keyboard on outside tap for  edittext, in android.?


Jayden Bell
Jayden Bell

Total Post:105

Points:739
Supported
Posted on    February-27-2015 5:53 AM

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);
      } 

Don't want to miss updates? Please click the below button!

Follow MindStick