这是我的Android应用程序的一部分,我创建了一个webview ...但是当我点击webview中的任何链接时......没有任何反应......这是我的代码...我想发布任何浏览器或任何已安装的下载管理器中的链接... ima newbie..please帮助我解决这个问题
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Show the Up button in the action bar.
setupActionBar();
// no need to use title bar
requestWindowFeature(Window.FEATURE_NO_TITLE);
// set webview as main content only
mWeb = new WebView(this);
setContentView(mWeb);
// set Javascript
WebSettings settings = mWeb.getSettings();
settings.setJavaScriptEnabled(true);
// the init state of progress dialog
mProgress = ProgressDialog.show(this, "Loading", "Please wait for a moment...");
// add a WebViewClient for WebView, which actually handles loading data from web
mWeb.setWebViewClient(new WebViewClient() {
// load url
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
// when finish loading page
public void onPageFinished(WebView view, String url) {
if(mProgress.isShowing()) {
mProgress.dismiss();
}
}
});
// set url for webview to load
mWeb.loadUrl("http://vesit-d7b.host22.com/Assignments/ECCF.html");
}
答案 0 :(得分:0)
请使用此代码并检查您的网址是否被网页视图捕获。
myweb.setWebViewClient(new WebViewClient() {
@Override
public void onPageStarted(WebView view, String url,
Bitmap favicon) {
Toast.makeText(this,url,Toast.LENGTH_SHORT).show();
}
@Override
public void onPageFinished(WebView view, String url) {
dialog.dismiss();
}
});
答案 1 :(得分:0)
点击链接后查看网址是什么.....
mWeb.setWebViewClient(new WebViewClient() {
// load url
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Log.v("here","the link is ::" + url);
view.loadUrl(url);
return true;
}
然后在浏览器上复制它以查看它是否是有效的链接..
答案 2 :(得分:0)
@Ritesh删除它将起作用的shouldOverrideUrlLoading方法