嘗試創建WebView,但它只顯示空白/白頁。我跟了幾個例子,他們都表示,與此代碼的工作...Android WebView顯示空白頁
這裏是我的代碼:
import android.app.Activity;
import android.os.Bundle;
import android.webkit.WebView;
public class PostenWebView extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view);
WebView webview = (WebView)findViewById(R.id.webview);
webview.loadUrl("http://www.google.com");
}
}
這裏是web_view.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<WebView
android:id="@+id/webview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</LinearLayout>
我也有這個問題。我的代碼: \t \t mWebView =(WebView)findViewById(R.id.web_view); \t \t mWebView.getSettings()。setJavaScriptEnabled(true); \t \t mWebView.getSettings()。setSavePassword(false); \t \t url =「http://www.google。com「; \t \t \t mWebView.loadUrl(url); 直到方向改變後才顯示網頁,然後頁面顯示正常 – Richard 2010-07-07 17:07:26
同樣的問題在這裏直到方向才顯示網頁改變或點擊webview,然後頁面顯示正常,任何解決方案! – user4500 2013-04-04 13:43:25