Apurva
Apurva

Reputation: 11

Web View in Android

In my android app whole web page is loading in web view to which i gave the link, but I want to load only some component from that web page not rest of the component. Can anybody tell me is it possible to load only required component from web page and how?

Upvotes: 0

Views: 142

Answers (2)

Carnage
Carnage

Reputation: 117

It can be done using Jsoup html parsing library.

1.Get the data from url to jsoup document.

Document doc = Jsoup.connect("http://example.com/").get();

  1. remove the unwanted content html tag using remove().

    doc.select("span[style*=display:none]").remove(); //put unwanted tag inside.

  2. Save the remaining content to a string.

    String newcontent=doc.toString();

4 Set the newcontent as Webview content.

webView.loadDataWithBaseURL(null, newcontent, "text/html", "UTF-8", null);

Sorry for poor english.

Upvotes: 1

ZeusNet
ZeusNet

Reputation: 720

I dont know if there is a standard api to do this, but if not you could load the html first then manipulate it. So you could delete the areas you dont need and only display the necessary parts.

Cheers

Upvotes: 0

Related Questions