我需要在我的 android 应用程序中显示一个 Webview。问题是我要显示的网页出现错误:
"This page contains the following errors:
error on line xxx at column xxx: Entity 'abc' is not defined
Below is the rendering of the page upto the first error"
该网站在我的移动浏览器和我的桌面上运行良好。另外,我没有在其他网站上收到此错误
无论如何我可以避免这个错误。请帮忙。
这是java代码:
public class Zero extends Activity {
WebView wv;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_PROGRESS);
setContentView(R.layout.zero);
wv=(WebView) findViewById(R.id.web);
wv.getSettings().setJavaScriptEnabled(true);
//wv.loadUrl("http://customercare.indianrailways.gov.in/criscm/common/complaint_registration.seam");
wv.loadUrl("http://ndtv.com");
wv.setWebViewClient(new HelloWebViewClient());
final Activity activity = this;
wv.setWebChromeClient(new WebChromeClient(){
public void onProgressChanged(WebView view, int progress) {
activity.setTitle("Loading...");
activity.setProgress(progress * 100);
if(progress == 100)
activity.setTitle("Easy Complaint Indian Railways");
}
});
}
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && wv.canGoBack()) {
wv.goBack();
return true;
}
return super.onKeyDown(keyCode, event);
}
}
布局xml文件:
<?xml version="1.0" encoding="utf-8"?>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/web">
</WebView>