安卓:ListView控件与刷卡里面ViewPager [英] Android: ListView with Swipe inside ViewPager

查看:150
本文介绍了安卓:ListView控件与刷卡里面ViewPager的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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.

感谢

推荐答案

我的第一个想法是<一个href="http://developer.android.com/reference/android/view/ViewParent.html#requestDisallowInterceptTouchEvent%28boolean%29"相对=nofollow> 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);
    }
}

这篇关于安卓:ListView控件与刷卡里面ViewPager的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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