Issue
I know I can query if a WebView widget can go back or forward using the canGoBack() and canGoForward() methods. But I want to enable (or disable) toolbar buttons depending on whether the WebView can go back or forward and I don't want to poll canGoBack() and canGoForward() all the time so I'd need something like a listener that is called whenever the state of canGoBack() or canGoForward() changes.
Is something like that available? I fail to find anything like that in the WebView docs.
Solution
as far as I know there is no such listener, but what we can do is
setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(final WebView view, final String url) {
super.onPageFinished(view, url);
if (view.canGoBack()) {
//enable back button
} else {
//disable back button
}
if (view.canGoForward() {
//enable forward button
} else {
//disable forward button
}
}
});
Answered By - stallianz
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.