Reputation: 2593
how do I detect textbox click in webview? I want to pop-up the keyboard when user clicks on a textbox in a webview. I have my keyboard defined in code upon calling displayKeyboard() in my code will display it but how do i trigger that call?
Upvotes: 2
Views: 1297
Reputation: 7674
You can do something like this:
Button yourButton = new Button(context);
yourButton.setOnClickListener(this);
webView.addJavascriptInterface(yourButton,"injectedObject");
@Override
public void onClick(View v) {
//displayKeyboard()
}
The HTML button will be as:
<input type="submit" name="submit" id="some_id" onclick="yourButton.performClick();" />
You can also read about it addJavascriptInterface
As you don't have any control on the webpage, you might want to read this:
and
webview detuct html tag how android
And notice that you probably need to dearch for this:
int type = result.getType();
if (type == WebView.HitTestResult.EDIT_TEXT_TYPE) {
return;
}
Upvotes: 1