How to disable pullToRefreshScrollView from listening to touch

久未见 提交于 2020-01-04 23:04:28

问题


I am using pullToRefreshLibrary provided by Chris Banes. I have gridView which is containg whole list of data. I tried pullToRefreshGridViewActivity but it was too slow so I am trying to use pullToRefreshScrollViewActivity over my gridView to handle it. The problem is that when I do so, scrollView is handling all touch events and I cannot swipe over gridView. I need to lock it and pass touches to gridView. here is my xml :

<com.handmark.pulltorefresh.library.PullToRefreshScrollView
        xmlns:ptr="http://schemas.android.com/apk/res-auto"
        android:id="@+id/pull_refresh_scrollview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        ptr:ptrAnimationStyle="flip" >

        <com.asd.android.dda.ui.controls.ExpandableGridView
            android:id="@+id/gridview"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:clipToPadding="false"
            android:drawSelectorOnTop="true"
            android:fadingEdge="none"
            android:gravity="top"
            android:horizontalSpacing="@dimen/image_grid_hspacing"
            android:listSelector="@drawable/selector_shadow"
            android:numColumns="@integer/grid_num_cols"
            android:paddingBottom="50dp"
            android:scrollbarAlwaysDrawVerticalTrack="false"
            android:scrollbars="none"
            android:scrollingCache="true"
            android:smoothScrollbar="false"
            android:stretchMode="columnWidth"
            android:verticalSpacing="@dimen/image_grid_vspacing"
            android:visibility="visible" />
    </com.handmark.pulltorefresh.library.PullToRefreshScrollView>

I tried to lock scrollView with :

mScrollView.requestDisallowInterceptTouchEvent(true);
gridView.requestDisallowInterceptTouchEvent(true);

mScrollView.setOnTouchListener(new OnTouchListener(){ 
    @Override
    public boolean onTouch(View v, MotionEvent event) {
        return false; 
    }
});
mScrollView.setOnTouchListener(null);

But none of these work. And I can't use here custom ScrollView to override onInterceptTouchEvent.


回答1:


One hack you can use is to open the library, go into PullToRefreshBase.java and remove final from methods like onInterceptTouchEvent. You can then use a custom ScrollView.



来源:https://stackoverflow.com/questions/18639668/how-to-disable-pulltorefreshscrollview-from-listening-to-touch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!