i want to hide keyboard when user torches outside the Edit text but is not from activity but from fragment please any possible solution
Try to get EditTesxt focus status with setOnFocusChangeListener
and if it's not focused hide the keyboard:
editText.setOnFocusChangeListener((v, hasFocus) -> {
if (!hasFocus) {
InputMethodManager imm = (InputMethodManager) context.getSystemService(Activity.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
}
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.