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
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
