How to hide keyboard on outside tap for edittext, in android.

Total Post:183

Points:1285
 2231  View(s)
Ratings:
Rate this:
How to hide keyboard on outside tap for  edittext, in android.?
  1. 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);
          } 

      Modified On Apr-09-2018 01:50:27 AM

Answer