Reputation: 14390
i have small project its content listview
and each item inside listview
content html webview
and the webview content text
and images
my problem is i can't get the image src
on click
so i want to get clicked image src
without opening the image inside the webview
i've tried to add <a href
to the images but when i clicked on the image its open inside the webview
i don't want that all i want to get the image url
when i click on it is this possible ?
Upvotes: 0
Views: 2548
Reputation: 450
One way is if you are using shouldOverrideUrlLoading()
then you can check the url for image types:
public class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url == null){
return false;
}else if (url.trim().toLowerCase().endsWith(".img")) {//use whatever image formats you are looking for here.
String imageUrl = url;//here is your image url, do what you want with it
}else{
view.loadUrl(url);
}
}
}
Upvotes: 2