Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to hide keypad when click outside editText?

i have custom listview with editText and edit the edittext data on tapping edittext with help of showing keypad it is working fine .

my problem is when i click outside of edittext the keypad must hide.

thanks...

like image 684
Archana Avatar asked Oct 12 '11 05:10

Archana


2 Answers

For this you have to take the onTouchListener on the parent layout of the Layout File. on the TouchListener you have to code to hide the Keyboard when click outside the EditText. Please follow XML Layout and Java class to resolve this issue please follow following url.

http://amitthaperandroidquery.blogspot.com/2011/10/remove-keyboard-after-click-outside.html

like image 200
Amit Thaper Avatar answered Nov 09 '22 11:11

Amit Thaper


One way is that you can set a focus change listener to the EditText. When the widget loses focus you can hide the Keyborad by:-

InputMethodManager imm = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(myEditText.getWindowToken(), 0);
like image 32
amiekuser Avatar answered Nov 09 '22 11:11

amiekuser