滑动删除(SwipeListView)_侧滑删除



  1. 团购片段中

   private SwipeListView mListView;


修改lib_pull库中PullToRefreshListView类

public class PullToRefreshListView extends PullToRefreshAdapterViewBase<SwipeListView> {


private LoadingLayout mHeaderLoadingView;

private LoadingLayout mFooterLoadingView;

protected class InternalListView extends SwipeListView implements EmptyViewMethodAccessor {


private boolean mAddedLvFooter = false;


public InternalListView(Context context, AttributeSet attrs) {

super(context, attrs);

}

PullToRefreshListView继承的PullToRefreshAdapterViewBase<ListView>是一个泛型类,SwipeListView继承自ListView所以可以将SwipeListView作为泛型参数   


2.  xml中

 <com.handmark.pulltorefresh.library.PullToRefreshListView

        android:id="@+id/ptr_list"

        android:layout_below="@+id/tuangou_actionbar"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        android:cacheColorHint="#00000000"

        android:divider="#19000000"

        android:dividerHeight="4dp"

        android:fadingEdge="none"

        android:fastScrollEnabled="false"

        android:footerDividersEnabled="false"

        android:headerDividersEnabled="false"

        android:smoothScrollbar="true"

        ptr:ptrDrawableStart="@drawable/refresh_p_w_picpath" 

        ptr:ptrHeaderTextColor="#C59502"

        ptr:swipeBackView="@+id/back"

        ptr:swipeCloseAllItemsWhenMoveList="true"

        ptr:swipeDrawableChecked="@drawable/choice_selected"

        ptr:swipeDrawableUnchecked="@drawable/choice_unselected"

        ptr:swipeFrontView="@+id/front"

        ptr:swipeMode="both"/>

3、为SwipeListView设置setSwipeListViewListener()监听后,出现setOnItemClick()的事件监听失效

              解决办法:重写BaseSwipeListViewListener的onClickFrontView方法

              滑动删除(SwipeListView)_侧滑删除_02

4、滑动删除ListView的行布局对象时,出现行布局对象已被删除,但行布局对象还是显示为向左滑动的状态(显示为向左滑动删除的背景)。

              解决办法:滑动删除(SwipeListView)_侧滑删除_03

5.SwipeListView的headerView中有ViewPager控件,出现了滑动viewPager控件后,SwipeListView中所有控件的事件监听全部失效

              原因:SwipeListView截获了viewPager的滑动事件监听,导致了viewPager滑动无效。

                         滑动删除(SwipeListView)_侧滑删除_04

              解决办法:创建一个类继承ViewPager, 并重写滑动删除(SwipeListView)_侧滑删除_05

                                使SwipeListView不再抢占焦点