[英]Android Programming: swipe between tabs, remove at ends
I have a swipe between tabs feature in an app I am developing using a FragmentPagerAdapter. 我正在使用FragmentPagerAdapter开发的应用程序中的选项卡功能之间滑动。 My question is: how do I prevent the "can't go any further" animation for swiping at the first and last view? 我的问题是:如何防止在第一个和最后一个视图上滑动“不能再走”动画了?
So, say you have three tabs and you're already on the most far right tab. 因此,假设您有三个标签,并且您已经在最右边的标签上。 If you try to swipe right again, that gray/black shadow shows up, indicating that you can't go any further. 如果您尝试再次向右滑动,则会显示灰色/黑色阴影,表示您无法再进行任何操作。
如果使用的是FragmentPagerAdapter,则它是FragmentPagerAdapter的默认功能。
you can use the below code to show the alert to user. 您可以使用以下代码向用户显示警报。
public void onPageScrollStateChanged(int state) {
int currentPage = pager.getCurrentItem(); //ViewPager Type
if (currentPage == 3 || currentPage == 0){
//Write your custom logic here.
}
}
Hope this will help to you. 希望这对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.