Last active
December 26, 2015 23:19
-
-
Save creativepsyco/7229277 to your computer and use it in GitHub Desktop.
Hide the keyboard from view
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Very useful to capture the focus if there is a need to | |
// Currently this hides the keyboard from the view | |
// If the underlying view is not an EditText | |
// For this to work all the parent layouts | |
// must declare themselves as focusableinTouchMode | |
// Focusable and clickable | |
@Override | |
public boolean dispatchTouchEvent(MotionEvent ev) { | |
View v = getActivity().getCurrentFocus(); | |
boolean ret = super.dispatchTouchEvent(ev); | |
View w = getActivity().getCurrentFocus(); | |
if (!(w instanceof EditText)) { | |
// Edit Text losing focus | |
// Hide the keyboard here or anything else that you wanna do. | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment