-3

hi developers i am working in a webview in android. i loaded a webpage in WebView. then i click some link that contains in the webpage. Then i click the goback button in my application the onclick of the button contains the below code

webview.canGoBack();
 backbutton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
                      webview.goBack();
                    }
                 });

but this code works only once. it goes only one clicked link back. i want to goback the every clicked url one by one

Ribin Haridas
  • 127
  • 2
  • 10

2 Answers2

1

Please try it.

backbutton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
        if (webView.canGoBack()) {
            webView.goBack();
        }
    }
});
Adi Inbar
  • 12,097
  • 13
  • 56
  • 69
nilesh patel
  • 834
  • 1
  • 5
  • 10
  • can you vote up this question please. because i cant ask other question – Ribin Haridas Jul 17 '13 at 11:08
  • Thank you for your answer nilesh its works well. Thank you again – Ribin Haridas Jul 17 '13 at 11:11
  • @nileshpatel You provide some good answers, but please learn how to use code blocks properly: http://stackoverflow.com/editing-help. Two hints: 1. Any line that's indented at least 4 spaces will be in a code block, so if you don't add 4 spaces to the whole thing, the lines at the leftmost level will be left out. 2. You don't need to add 4 space to each line manually. Just select the code and click the **{}** in the tool bar. – Adi Inbar Jul 31 '13 at 21:04
0

You can initiate another loading if you override onPageFinished method of WebViewClient or if you modify shouldOverrideUrlLoading.

xlm
  • 6,854
  • 14
  • 53
  • 55