Before I made a native android app which contains a number input. when you click in it numeric keyboard of android pops up which has done button which hides keypad after clicking done button. but now i have made another similar app but it contains WebView so it is a website created using html,JavaScript, css etc. which has <input type ="number"/>
and again numeric keypad of android pops up but no done button in it. it looks like the webview is handled by browser keypad. is it possible to add done button here?
-
can't you use keyUp and keyDown override method to achieve ur task?– Lokesh DesaiJan 19, 2018 at 6:40
Add a comment
|
2 Answers
Please check out the following trick in Menifest.xml file for the activity which is having your webview
AndroidManifest.xml
<activity android:name="..."
...
android:imeOptions="actionSend|flagNoEnterAction"
...
</activity>
Hope it works.
-
Hi, thank you for help. Its not working.I am working with webview Jan 22, 2018 at 14:34
-
1@KanwalGill I think this article can help you exactly for what you looking to implement. Please try this. android.jlelse.eu/managing-keyboard-on-webview-d2e89109d106 Hope this helps. Jan 23, 2018 at 4:21
-
Welcome @KanwalGill. Please accept my answer if it worked for you. Jan 23, 2018 at 5:06
Sharing code how i am detecting EditText in Webview
mWebView = (MyWebView) findViewById(R.id.webview);
mWebView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
WebView.HitTestResult hr = ((WebView)v).getHitTestResult();
int type = hr.getType();
if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) {
//Calls When user touch edittext in webview
//Open Keyboard with done button programatically
return;
}
return false;
}
});
This is working fine for my task...Hope this help you also