Hide keypad in android while touching outside Edit Text Area

后端 未结 3 2243
失恋的感觉
失恋的感觉 2021-02-20 10:50

I know that the code for dismiss tyhe keypad in android is

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hide         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 11:38

    Best way you can use is DONE button besides EditText make your onClickListener to do like,

    done.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View arg0) {
            InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
    }
    });
    

提交回复
热议问题