-1

I have a request from a client which says something like this: after a user inserts his name, on tap out validate with server.

I never heard about tapping out from a field in Android yet. (tap out means when you are writing something into an EditText, then you click on other view, hide keyboard and call focus change listener).

Do you have any idea about this implemented in Android? Thanks.

Update, after marked duplicated: I already did my research for this a lot, this is why I asked here for an opinion.

The above case is just an example. My main interest is regarding tapping out from EditText (TAP on another view with NO action - e.g. a TextView with no clickable function). I hope it's clear now.

sunlover3
  • 1,999
  • 1
  • 20
  • 25
  • 1
    Possible duplicate of [How to use onBlur function on EditText in android?](https://stackoverflow.com/questions/8322207/how-to-use-onblur-function-on-edittext-in-android) – Tim Biegeleisen Jan 05 '18 at 11:07
  • Just add a blur handler which does the validation. Actually, you might want to do client side validation first, and only do server side validation when the user actually tries to submit the form. Follow the duplicate link to get started. – Tim Biegeleisen Jan 05 '18 at 11:08
  • just add a clicklistner in the layout also. And on clicking it perform your operation – Ranjan Jan 05 '18 at 11:10
  • @TimBiegeleisen Thanks for your answer. It's not what I am searching for, though. I updated the question. – sunlover3 Jan 05 '18 at 12:17

1 Answers1

1

You can force Android to hide the virtual keyboard using the InputMethodManager, calling hideSoftInputFromWindow, passing in the token of the window containing your focused view.

InputMethodManager methodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
if (methodManager != null) {
     methodManager.hideSoftInputFromWindow(mEditText.getWindowToken(),0);
}
theboringdeveloper
  • 1,429
  • 13
  • 17
  • It's true, I can do this. But the question is regarding on tapping out action. I mean, this code I can put it inside OnFocusChangeListener, but this is not the point. Thank you anyway! – sunlover3 Jan 05 '18 at 12:14