Android 网页视图选择

发布于 2024-12-07 14:46:52 字数 825 浏览 2 评论 0原文

我只想在设备屏幕上显示 ,没有所有其他不必要的东西,来自此网页。到目前为止,这是我的代码...

package com.nextlogic.hellowebview;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class HelloWebView extends Activity {
    /** Called when the activity is first created. */
    WebView mWebView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("http://golfnews.no/nyheter.php?a=2013");
    }
}

你能帮我吗?我们将不胜感激。谢谢。

I would like to show on the device's screen only this
, without all the other unnecessary stuff , from this web page. This is my code so far...

package com.nextlogic.hellowebview;

import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;

public class HelloWebView extends Activity {
    /** Called when the activity is first created. */
    WebView mWebView;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.loadUrl("http://golfnews.no/nyheter.php?a=2013");
    }
}

Could you please help me ? It would be much appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

姜生凉生 2024-12-14 14:46:52

您需要的是一个 HTML 解析器,例如 JSOUP。一个很棒的解析器,我将它用于很多项目。

这将允许您仅解析特定内容,

例如网页中的图像网址,然后将其检索到位图并将其设置为图像视图(最好为此使用异步任务),然后您可以使用标签来检索文本。

如果您需要这方面的帮助,请告诉我。

编辑:如何使用 jsoup 解析您的网页:

Document doc = Jsoup.parse("http://golfnews.no/nyheter.php?a=2013").get();
Elements article-text = doc.select(div.article);
//just to verify.
System.out.println(article-text.text());



TextView TextArticle = (TextView)findViewById(R.id.YOURTEXTVIEW);
TextArticle.setText(article-text.text());
//OR
String article = article-text.text();
TextArticle.setText(article);

尝试一下。

编辑: 如何添加外部 jar

What you will need is a HTML Parser such as JSOUP. A great parser i use it for alot of projects.

This will allow you to parse only specific content,

Such as the image url from your webpage, and then retrieve it to a bitmap and set it to a imageview(Best to use an asynctask for this) and then you can use tags to retrieve the text.

Let me know if you need help with this.

EDIT: How to parse your Webpage with jsoup:

Document doc = Jsoup.parse("http://golfnews.no/nyheter.php?a=2013").get();
Elements article-text = doc.select(div.article);
//just to verify.
System.out.println(article-text.text());



TextView TextArticle = (TextView)findViewById(R.id.YOURTEXTVIEW);
TextArticle.setText(article-text.text());
//OR
String article = article-text.text();
TextArticle.setText(article);

Try this out.

EDIT: How to add external jar's

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文