We can use the webview method to navigate forward and backward. The logical canGoForward() method for Gets whether this WebView has a forwarding history element. canGoBack() for Gets whether this WebView has a history history element. goBack() returns to the history of this WebView and goForward() returns to the history of this WebView. this is my implementation:
@Override public void onClick(View v) { switch (v.getId()){ case R.id.forward_btn: if (mWebView.canGoForward()){ mWebView.goForward(); }else{ Toast.makeText(getApplicationContext(), "Tidak ada halaman lagi!", Toast.LENGTH_SHORT).show(); } break; case R.id.backward_btn: if (mWebView.canGoBack()){ mWebView.goBack(); }else{ Toast.makeText(getApplicationContext(), "Tidak bisa kembali!", Toast.LENGTH_SHORT).show(); } break; case R.id.reload_btn: layoutLoading.setVisibility(View.VISIBLE); mWebView.reload(); break; case R.id.back_btn: onBackPressed(); break; } }
source share