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
<input type="submit" name="submit" id="submit_id" onclick="btnLogin.performClick();" />
to
<input type="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(new MyWebViewClient());
public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if ( url.equals("http://www.google.com") ){
Log.d("debugging","we can do something here");
}
return true;
}
}
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"