如何在android中禁用webview一段时间
假设我有 10 个网页。我第一次加载第一页,当用户滑动屏幕时将加载下一页。因此,当用户滑动屏幕时,我会增加网页计数。但问题是在加载页面时,如果用户多次滑动屏幕,则 Web 视图会加载页面,该页面会因用户在加载时进行不必要的滑动而增加。 我想禁止用户在页面加载时触摸 webview 屏幕。我怎样才能做到这一点?
Assume i have 10 web page. First time im loading 1st page and the next page will be loaded when user swipes the screen.so i incrementing web page count when the user swipes the screen. but problem is while loading a page if user swipes the screen many times then web view loades the page that is incremented by the unnecessary swipe done by the user while loading.. So
i want to disable the user to touch the webview screen while page loading . how can i do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我从你的描述中得到的是,如果用户从第 1 页滑动到第 2 页,并且页面正在加载,如果用户滑动 3 次,那么它将加载第 2,3,4,5 页,并且你想要禁用滑动,除非第 2 页已加载。如果我是正确的,那么下面是我的解决方案
在
onfling()
方法中检查boolean
页面是否完全加载,如果没有,则返回而不进行进一步处理,我想您用于下载代码的代码将不会运行。在调用下载方法之前必须将此布尔值设置为 false,并在下载完成时设置为 true。除此之外,我建议加载用户最终滚动到的特定页面,而不是禁用滑动,因为您无需执行任何操作
onFling
只需检查下载器线程
code> 最后一页是否处于活动状态,如果是,则中断它并为当前页面重新启动它我认为这种方法对用户更友好What I get from your description is that if user swipe from Page 1 to Page 2 and the page is loading in the mean time if user swipe 3 times then it will load Page 2,3,4,5 and you want disable swipe at unless Page 2 has been loaded. If I am correct then below is my solution
In
onfling()
method check forboolean
that whether the page is completely loaded or not if not then return without further processing and I suppose your code for downloading the code will not run. This boolean must be set false before you call the downloading method and set to true where the downloading is finished.Apart from this I will suggest to load that particular page on which the user finally scrolls to rather than disabling the swipe for that you will have to do nothing
onFling
just check whether thedownloader thread
is alive for the last page or not if yes interrupt it and start it again for the current page I think this approach is more user friendly