我有一个 WebView,我在点击后退按钮时使用 WebView.goBack(),我在另一个地方使用 WebView.goBackOrForward(x)。
我的问题是,为什么 WebView.goBackOrForward(x) 从互联网再次加载访问过的网页,而 WebView.goBack() 不会再次加载访问过的网页并快速显示以前的网页?
最佳答案
如 doc :
goBack
Added in API level 1
void goBack ()
Goes back in the history of this WebView.
代替
goBackOrForward
Added in API level 1
void goBackOrForward (int steps)
Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
我假设确切地知道 WebView 将要加载哪个页面会使它更快,因为 goBack
它总是加载上一页。 goBackOrForward
在加载之前需要计算它需要加载的页面。我不确定,你应该检查代码。
关于android WebView goBackOrForward() 与 goBack(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40680890/