Android custom keyboard in web review

I am trying to implement a custom keyboard on Android. I want to enter some text in my webview. Since I don't want to display the keyboard when I get everywhere in Webview, I thought of a listener something like this:

webview.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { // TODO Auto-generated method stub if (((WebView) v).getHitTestResult().getType() == EDIT_TEXT_TYPE) showMyKeyboardHere(); return false; } }); 

my listener seems to return EDIT_TEXT_TYPE to the keystroke that I do AFTER I hit the edit text box. So when I click the edit text box, it returns UNKNOWN_TYPE, and clicking after that when clicked elsewhere returns EDIT_TEXT_TYPE. I assume that OnTouchListener will happen before touch even goes to Webview, it has not registered it. Any way to change this?

Now to my question: since I only want my custom keyboard in this application, is it all the same to listen to any event called to call a normal keyboard and immediately hide it and show my own?

+4
source share

Source: https://habr.com/ru/post/1497320/


All Articles