first you must work with some html code, creating a template for your webview...
String TemplateHTML =
"<div id=\"content\">[Replace with your CONTENT]</div><div id=\"myimage\"><a id=\"mylink\" onClick=\"window.demo.clickOnAndroid()\"><img id=\"myImage\" src=\"[Replace your image URL path]\" /></a></div>"
Create JSInterface to interact with your template
final class myJavaScriptInterface {
myJavaScriptInterface () {
}
public void clickOnAndroid() {
mHandler.post(new Runnable() {
public void run() {
Log.i("myJavaScriptInterface " ,"Jorge is Clickin the image!!! =D");
}
});
}
}
add the interface and your Template to your webview!
MyWebView.addJavascriptInterface(new myJavaScriptInterface (), "demo");
MyWebView.loadDataWithBaseURL(null, TemplateHTML, "text/html", "utf-8", null);
WebSettings webSettings = WebContent.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(true);