1

i want to detect <img click inside webview ? if so how ? i need an example plz

so far as i know i can detect <a href click inside webview by useing WebViewClient

but i need to detect <img click without using java script can i ?

this is my code :

WebView webview = ( WebView ) findViewById(R.id.wv);

WebSettings settings = webview.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadsImagesAutomatically(true); 


String summary = "<html><body>You scored <fieldset><legend>adfadf</legend>"
                    + " <a href='http://192.168.1.100/1.jpg'><img src='http://192.168.1.100/1.jpg' /></a> </fieldset> "
                    + " <b>192</b> points.</body></html>";


webview.loadData(summary, "text/html", null);
Kodr.F
  • 13,932
  • 13
  • 46
  • 91

1 Answers1

3

Refer this answer,

Detect click on HTML button through javascript in Android WebView

Same procedure track image click as well. If it doesn't work, create a button in HTML and place the image as background for the button, so you can track the button using answer given in the link.

Thanks.

Community
  • 1
  • 1
sais
  • 803
  • 6
  • 15
  • if i have multi images inside webview how i can catch them all ! that is the point – Kodr.F Jan 28 '14 at 19:23
  • Send a parameter(like ID) in function you give onclick attribute, so you can identify which image is being clicked. – sais Jan 29 '14 at 09:17