在最后一个屏幕上滑动时的Android ViewPager [英] Android ViewPager when swiping on last screen

查看:162
本文介绍了在最后一个屏幕上滑动时的Android ViewPager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法弄清楚如何捕获视图寻呼机最后一页上的滑动事件.

Im having trouble figuring out how to capture a swipe event on the last page of a view pager.

基本要求是,当用户在最后一页上并且尝试滑动到下一页时,活动应关闭.

Basically the requirement is that when the user is on the last page, and they try to swipe to get to the next page, the activity should close.

我尝试在onPageScrolled上执行此操作,但是在其中似乎无法区分向左或向右滑动.在最后一页上,用户仍应保留移至上一页的功能.

I've tried doing this onPageScrolled but I cant seem to differentiate a left or right swipe when in there. When on the last page, the user should still maintain the functionality to move to the previous page.

所以基本上是这样

When on last page
    if swipe prev (do normal behaviour)
    if swipe next (finish activity)

任何人都可以提供任何建议吗? 谢谢

Can anyone provide any suggestions? Thanks

推荐答案

您应该在ViewPager中包含一个伪造的空白页,当用户滑动您的实际最后一页时,就会出现此伪造的空白页.当此伪造品可见时,请完成Activity.

You should include an fake blank page to your ViewPager, when user swipes your actual last page, it comes to this fake one. When this fake one is visible finish the Activity.

您应该尝试这种方式,如果它不起作用,我可以给您一个示例代码.

You should try this way, if it does not work, I can give you an example code.

这篇关于在最后一个屏幕上滑动时的Android ViewPager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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