WebView 中 onOptionsItemSelected 菜单上用于“前进”的方法是什么?和“返回”在安卓中?
我试图通过调用菜单来让我的 webView 前后移动。到目前为止,我的菜单工作正常并打开,刷新按钮将刷新浏览器。但是,我在任何地方都找不到有关前进后退方法的文档。如果默认的互联网浏览器只需按菜单键就有它们,那么肯定就在那里。我只是找不到它们/不知道如何实现它们。任何帮助都会有益的,谢谢。
这是我想要做的:
WebView.Java:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_navigation, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back_button:
"???"
case R.id.forward_button:
"???"
case R.id.refresh_button:
refreshBrowser();
return true;
}
return false;
}
我缺少的部分由三个问号“???”标记。如果您需要更多信息来获得帮助,请告诉我,再次感谢。
I am trying to get my webView to move back and forward by calling up the menu. Thus far I have the menu working fine and opening, and the refresh button will refresh the browser. However, I cannot find documentation anywhere about the methods for forward of back. If the default internet browser has them by just pressing the menu key there must be out there. I just can't find them/don't know how to implement them. Any help would be beneficial, thank you.
Here is what I am trying to do:
WebView.Java:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu_navigation, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.back_button:
"???"
case R.id.forward_button:
"???"
case R.id.refresh_button:
refreshBrowser();
return true;
}
return false;
}
The part that I'm missing is marked by the three question marks "???". Let me know if you need more information to get some help, and thanks again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 webView.canGoBack 和 webView.canGoForward 检查是否有历史数据可以后退/前进,然后加载该 url。
Use webView.canGoBack and webView.canGoForward to check if there is history data to go back / forward and then load that url.