3
如何在網站的webview期間沒有任何連接時顯示錯誤消息。也有什麼辦法來隱藏像501,404等網頁錯誤 在此先感謝,我是新的android應用程序,所以請詳細。通過eclipse連接和頁面錯誤的webview錯誤
package com.website;
import android.app.Activity;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.view.KeyEvent;
import android.view.Window;
import android.content.Context;
import android.net.NetworkInfo;
public class HelloWebView extends Activity {
WebView webview;
/** Called when the activity is first created. */
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webview.canGoBack()) {
webview.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
WebView.enablePlatformNotifications();
webview.getSettings().setJavaScriptEnabled(true);
webview.setScrollBarStyle(WebView.SCROLLBARS_INSIDE_OVERLAY);
webview.loadUrl("http://www.google.com/");
webview.setWebViewClient(new HelloWebViewClient());
}
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
你的'HelloWebViewClient'很奇怪。它的用途是什麼? – Olegas 2011-04-04 07:01:34
我從android開發人員演示http://developer.android.com/resources/tutorials/views/hello-webview.html – 2011-04-04 07:39:21