1. 程式人生 > 實用技巧 >cc美團 滑動刪除(SwipeListView)

cc美團 滑動刪除(SwipeListView)

wKiom1WpNU-yOeTrAAGRJhRvb-Q076.jpg



  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方法

7C18C89EF638439FB006D3BE2CAAC88B

4、滑動刪除ListView的行佈局物件時,出現行佈局物件已被刪除,但行佈局物件還是顯示為向左滑動的狀態(顯示為向左滑動刪除的背景)。

解決辦法:C4EED69CBB43413FB4E74910C90B2CEC

5.SwipeListView的headerView中有ViewPager控制元件,出現了滑動viewPager控制元件後,SwipeListView中所有控制元件的事件監聽全部失效

原因:SwipeListView截獲了viewPager的滑動事件監聽,導致了viewPager滑動無效。

D755B8F8B0C9481EACE1F700360E936F

解決辦法:建立一個類繼承ViewPager, 並重寫D91EAB129F0E46F5A3E7D8282F7F1D6B

使SwipeListView不再搶佔焦點



感謝: 國賢、地土、國湞、其鵬、家鑫的幫忙,新博18班這個大集體,我們會一直互助,一起進步

轉載於:https://blog.51cto.com/1137907860/1675844