在Android的Web视图中使用“后退"按钮 [英] Using the Back button in a webview in Android

查看:108
本文介绍了在Android的Web视图中使用“后退"按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用普通的移动浏览器时,按后退"按钮,它将带您到上一页.当我的应用程序中使用WebView来显示网页并且用户想要返回上一页时,通常如何做?按下后退"按钮会自动将用户带回到上一页还是将用户带回到上一个活动?我假设由于后退"按钮通常是用于将用户带到上一个活动,因此不应将其用于返回上一个网页.如果是这种情况,我的移动网页是否应该包含用户单击的自己的后退"链接?

When using the normal mobile browser, when you press the Back button, it takes you to the previous page. When a WebView is used in my app to display a web page and the user wants to return to the previous page, how is typically done? Does pressing the Back button automatically take the user back to the previous page or does it take them back to the previous Activity? I would assume that since the Back button is normally meant to take the user to the previous activity, it shouldn't be used to return to a previous web page. If this is the case, should my mobile web page include its own Back link that a user clicks on?

我想我想做的是了解我应该采用的正确行为.

I guess what I am trying to do is to understand the correct behavior I should be employing.

推荐答案

请注意,大多数android设备都随附有后退按钮.因此,您不需要在活动中使用后退"按钮即可返回上一个活动.

Please keep in mind that back buttons is coming with majority of the android devices. So you do not need a back button in your activity to go back to previous activity.

关于网络视图,如果您想让网络视图中的导航遍历所有先前的页面,则可以放一个后退按钮,并使用方法webview.goBack()来实现网络视图的导航.

And about the webview if you want navigation in the webview to travel all the previous pages then you can put a back button and implement the navigation of the webview using the method webview.goBack().

简而言之,如果您希望用户导航至上一页,则应提供Web视图的功能以返回上一页,并从第一页用户单击后退"按钮再次完成该活动.

In short, If you want your user to navigate to previous page then you should give functionality of the webview to go back to previous page and from the first page user click on back button again finish the activity.

这篇关于在Android的Web视图中使用“后退"按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆