5

How can I get String from webview on its click event??

here is the image:

enter image description here

here i just want to fetch the blue colored strings programmatically and not the other ones.

i am using Html string Display like this in

webview.setWebViewClient(new WebViewClient());   
webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);                             
webview.loadDataWithBaseURL("file:///android_asset/", main_data ,  "text/html", "UTF-8", " ");  

Edit: How i can i do this? Any one have an idea ?

Nezam
  • 4,122
  • 3
  • 32
  • 49
NagarjunaReddy
  • 8,621
  • 10
  • 63
  • 98

1 Answers1

0

I don't find anything to get the text directly. A workaround could be:

When you load the webview, you parse the html. Like described here

There you save all the links in a map, using the url as key and the text as value.

Then:

webview.setWebViewClient(new WebViewClient() {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

        String text = map.get(url);

        return super.shouldOverrideUrlLoading(view, url);
      }
});
Community
  • 1
  • 1
User
  • 31,811
  • 40
  • 131
  • 232