cc美團 滑動刪除(SwipeListView)
團購片段中
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方法
4、滑動刪除ListView的行佈局物件時,出現行佈局物件已被刪除,但行佈局物件還是顯示為向左滑動的狀態(顯示為向左滑動刪除的背景)。
解決辦法:
5.SwipeListView的headerView中有ViewPager控制元件,出現了滑動viewPager控制元件後,SwipeListView中所有控制元件的事件監聽全部失效
原因:SwipeListView截獲了viewPager的滑動事件監聽,導致了viewPager滑動無效。
解決辦法:建立一個類繼承ViewPager, 並重寫
使SwipeListView不再搶佔焦點
感謝: 國賢、地土、國湞、其鵬、家鑫的幫忙,新博18班這個大集體,我們會一直互助,一起進步
轉載於:https://blog.51cto.com/1137907860/1675844