Android Clicking A Button Inside A Webview
I'm trying to implement a button inside a webview, I'm using the following code : package com.example.tests; import android.os.Bundle; import android.annotation.SuppressLint; impo
Solution 1:
Change
<inputtype="submit" name="submit"id="submit_id" onclick="btnLogin.performClick();" />
to
<inputtype="submit" name="submit"id="submit_id" onclick="login.performClick();" />
Because your Interface
name is login not btnLogin
For more info see this best post Android webview JavaScript Interface
Solution 2:
A tip: You can override opened links (<a href=
) with the WebView:
myWebView.setWebViewClient(newMyWebViewClient());
publicclassMyWebViewClientextendsWebViewClient {
@OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url) {
if ( url.equals("http://www.google.com") ){
Log.d("debugging","we can do something here");
}
returntrue;
}
}
Solution 3:
Check out this post : http://vshivam.wordpress.com/2013/07/04/week-2-5-androidjsbridge/ This is how you'd go about accessing android methods from JS.
Do comment if things are not clear.
Solution 4:
you can add your javascript.js file in the assest folder do your coding whatever you want.
Inside the html you can add onclick="callFunction();
to any the tag. and you are done...
Post a Comment for "Android Clicking A Button Inside A Webview"