我一直在尝试使用webview过去一小时,但我无法绕过它,这真让我烦恼..
我不知道我的应用程序中是否存在错误,或者我是以错误的方式执行此操作 和 无论我尝试什么,页面都无法加载
我已经包含了INTERNET的许可
代码如下 对于启动webview的活动如下
dialog=ProgressDialog.show(this,"loading","please wait...",true);
dialog.setCancelable(false);
Uri url = getIntent().getData();
webView = (WebView) findViewById(R.id.webview2);
webView.setWebViewClient(new client(this));
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.loadUrl(url.toString());
和webviewclient代码如下
class client extends WebViewClient {
Context c;
client(Context c) {
this.c=c;
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.d("viru","overide");
dialog.show();
view.loadUrl("http://www.google.com");
return true;
}
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
Log.d("viru","started");
Toast.makeText(c, "page started", Toast.LENGTH_LONG).show();
}
@Override
public void onPageFinished(WebView view, String url) {
Log.d("viru","finished");
Toast.makeText(c, "page finished", Toast.LENGTH_LONG).show();
dialog.dismiss();
}
}
logcat持续吐痰如下
01-24 14:58:25.858 28975-28975/com.example.viru.webview D/viru: started
01-24 14:58:26.263 28975-28975/com.example.viru.webview D/viru: started
01-24 14:58:26.409 28975-28975/com.example.viru.webview D/viru: overide
01-24 14:58:26.416 28975-28975/com.example.viru.webview D/viru: finished
01-24 14:58:26.441 28975-28975/com.example.viru.webview D/viru: started
01-24 14:58:28.913 28975-28975/com.example.viru.webview D/viru: finished
01-24 14:59:15.226 28975-28975/com.example.viru.webview D/viru: overide
01-24 14:59:15.291 28975-28975/com.example.viru.webview D/viru: started
01-24 14:59:17.007 28975-28975/com.example.viru.webview D/viru: finished
请解释webview架构如何工作以及如何通过这个无限循环.. 它真的很烦我..... 提前谢谢......