enter image description here我正在webview上使用該webview上的活動,有一個後退按鈕(不是鍵盤上的後退按鈕),可點擊但不起作用。任何想法如何處理這個點擊webview按鈕。在webview的webview後退按鈕沒有導航到之前的活動/頁面
CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new WebViewClient() {
ProgressDialog progressDialog =
ProgressDialog.show(activity, Constants.EMPTY_VALUE, Constants.PLEASE_WAIT, true);
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url, headers);
return true;
}
public void onPageStarted(WebView view, String url, Bitmap favicon) {
if (activity != null && progressDialog != null) {
progressDialog.setCancelable(false);
}
updatePaymentUrl = null;
if (url.contains("callback-data")) {
webView.setVisibility(View.GONE);
showpDialog();
int indexQ = url.indexOf("?");
partUrl = url.substring(indexQ + 1, url.length());
speedOrderUpdateApi();
}
if (updatePaymentUrl != null) {
super.onPageStarted(view, updatePaymentUrl, favicon);
} else {
super.onPageStarted(view, url, favicon);
}
}
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
Logger.logInfo("errorCode = ", String.valueOf(errorCode));
Logger.logInfo("description = ", description);
Logger.logInfo("failingUrl = ", failingUrl);
super.onReceivedError(view, errorCode, description, failingUrl);
}
@Override
public void onPageFinished(WebView view, String url) {
if (activity != null && progressDialog != null) {
if (progressDialog.isShowing()) {
progressDialog.dismiss();
}
// If title not found hide webview
Logger.logInfo("view.getTitle() = ", view.getTitle());
if (view.getTitle() != null && "Not Found".equals(view.getTitle())) {
view.setVisibility(View.INVISIBLE);
Toast.makeText(activity, "Link Not Found", Toast.LENGTH_LONG).show();
}
}
}
});
// Not needed
Random random = new Random(System.currentTimeMillis());
int randomNumber = random.nextInt();
Logger.logInfo("urlTemp = ", url);
webView.loadUrl(url, headers);
}
不..這不是一個解決方案... onKeyDown()按鈕工作正常,但在webView我有一個BACK文本按鈕,我需要處理that.U可以看到附加的圖像。 –
檢查我的更新 – Max
不,這不是一個答案我認爲我應該在webView.client()的onPagefinished()內編寫代碼。 –