显示在web视图的Andr​​oid网页的一部分视图、网页、web、oid

2023-09-13 00:17:59 作者:予渡

我想打一个应用程序加载从网页到web视图的内容。我想只显示一个特定的事物在整个web视图,而不是网页的全部内容。

I want to make an app which loads the content from the webpage into webview. I want to show only a particular thing in the entire webview, not the whole content of the webpage.

下面是一个例子。如果我使用:http://us.m.yahoo.com/w/search%3B_ylt=A2KL8xs0vUBQMg0AwAkp89w4?submit=oneSearch&.intl=us&.lang=en&.tsrc=yahoo&.sep=fp&p=digital+cameras&x=0&y=0作为URL的web视图,它加载的web视图页面中的所有内容。但我想删除的页面标题,并显示在我的应用程序的web视图。

Here is an example. If I use: http://us.m.yahoo.com/w/search%3B_ylt=A2KL8xs0vUBQMg0AwAkp89w4?submit=oneSearch&.intl=us&.lang=en&.tsrc=yahoo&.sep=fp&p=digital+cameras&x=0&y=0 as the URL for the webview, it loads all the contents of the page on the webview. But I want to remove the banner of the page and show it on the webview of my application.

我用adblocker使用CSS标签都试过了,但就是不帮我。请给我一些想法来克服这个问题。

I have tried using adblocker using CSS tags, but that is not helping me. Please give me some idea for overcoming this problem.

感谢。

推荐答案

感谢您的回答Zyber。我曾经用注射的JavaScript在Android上的$ C $下的WebView解决了这个问题。

Thank You for the answer Zyber. I have solved it using injection of JavaScript in the code for WebView in android.

final WebView webview = (WebView)findViewById(R.id.browser);
webview.getSettings().setJavaScriptEnabled(true);
webview.setWebViewClient(new WebViewClient() {
 @Override
public void onPageFinished(WebView view, String url)
{
    webview.loadUrl("javascript:(function() { " +
            "document.getElementsByTagName('header')[0].style.display="none"; " +
            "})()");
}
});
webview.loadUrl("http://code.google.com/android");

此解决我的目的,这是容易使用到

This solved my purpose and it is easy to use to.