【发布时间】:2014-03-17 04:32:17
【问题描述】:
我正在为 www.platform-online.net 创建一个 RSS 阅读器,我完全不知道为什么按下 RSS 链接时网页不会显示。
我确定它以某种方式涉及 webview,所以我给你两个涉及它的类:
> package com.daryl.rssreader;
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.webkit.*;
import com.daryl.platform.R;
public class PostViewActivity extends Activity {
private WebView webView;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.postview);
Bundle bundle = this.getIntent().getExtras();
String postContent = bundle.getString("content");
webView = (WebView)this.findViewById(R.id.webview);
WebSettings webSettings = webView.getSettings();
webSettings.setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient());
webView.loadData(postContent, "text/html; charset=utf-8","utf-8");
}
@Override
protected void onDestroy() {
// TODO Auto-generated method stub
super.onDestroy();
}
}
名为“postview.xml”的 XML 文件
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout android:id="@+id/LinearLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
如果我没有提供足够的信息来查看问题,请原谅我,但如果需要,我可以提供更多细节。
我会向您展示应用程序现在如何显示的链接,但我没有足够的“声誉”。
完全不知所措,代码大多来自这里: http://jmsliu.com/1390/rss-reader-app-android-tutorial-1-listview-and-arrayadapter.html
但该人并未对解决方案提供太多帮助。
如果有人能够在对我迄今为止所做的所有事情进行了 12 小时的分析后帮助我,我将不胜感激,因为我完全是一堵墙。
谢谢。
【问题讨论】:
-
所以我尝试在链接上使用教程中使用的xml链接,它显示网页很好,所以它必须是平台提供的rss提要。但是当我用 Platform (platform-online.net/feed?paged=) 替换它时,问题又回来了。但这现在是我卡住的地方。所以也许它不是网络视图,而是 RSS 提要本身?
-
如果有帮助,该网站也正在关闭 WordPress.org。
标签: android xml eclipse webview rss