Android: ListView with Swipe inside ViewPager(Android:在 ViewPager 内滑动的 ListView)
问题描述
我有一个包含整个活动的 ViewPager 活动.这个 ViewPager 内部是一个 ListView,它只覆盖了片段的底部.ListView 可以识别滑动事件(您可以左右滑动项目),但是当您想要滑动列表项时,ViewPager 会切换页面,因此它不起作用.有没有一种简单的方法来处理这个问题,以便 ViewPager 不会接收到用于列表的触摸事件.
I have an activity with a ViewPager that covers the whole activity. Inside this ViewPager is a ListView, that only covers the bottom part of the fragment. The ListView recognizes swipe events (you can swipe Items left and right) but when you want to swipe a list item the ViewPager switches the page, so it doesn't work. Is there an easy way to deal with this problem, so that the ViewPager doesn't receive the touch events that are intended for the list.
谢谢
推荐答案
我的第一个想法是requestDisallowInterceptTouchEvent() 可以帮助你.
My first idea is requestDisallowInterceptTouchEvent() may help you.
public boolean onTouch(View v, MotionEvent e) {
if(e.getAction() == MotionEvent.ACTION_DOWN){
listItem.getParent().requestDisallowInterceptTouchEvent(true);
}
}
这篇关于Android:在 ViewPager 内滑动的 ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android:在 ViewPager 内滑动的 ListView
基础教程推荐
- 如何比较两个 NSDate:哪个是最近的? 2022-01-01
- 为什么姜饼模拟器方向卡在应用程序中? 2022-01-01
- iOS - UINavigationController 添加多个正确的项目? 2022-01-01
- Xcode UIView.init(frame:) 只能在主线程中使用 2022-01-01
- SwiftUI-ScrollViewReader的ScrollTo不滚动 2022-01-01
- Android Volley - 如何动画图像加载? 2022-01-01
- UIImage 在开始时不适合 UIScrollView 2022-01-01
- Play 商店的设备兼容性问题 2022-01-01
- navigationItem.backBarButtonItem 不工作?为什么上一个菜单仍然显示为按钮? 2022-01-01
- 如何将图像从一项活动发送到另一项活动? 2022-01-01
