Android SwipeListView中的一个bug
最近我正在使用Android SwipeListView库,这是一个很棒的工作。 直截了当地说,我的要求是,当我向左滑动一个项目时,其他项目必须关闭。然后,当我打开第一个项目后,我再次开始非常非常缓慢地向左滑动第二个项目,同时我的手指仍在触摸屏幕。在开始打开时(BaseSwipeListView中的onStartOpen()),打开的项目很快关闭。当打开的门开始关上时,我停止了移动手指。结果,第二个项目停止在那里。结果如下: 同时,我的布局是:Android SwipeListView中的一个bug,android,listview,swipe,Android,Listview,Swipe,最近我正在使用Android SwipeListView库,这是一个很棒的工作。 直截了当地说,我的要求是,当我向左滑动一个项目时,其他项目必须关闭。然后,当我打开第一个项目后,我再次开始非常非常缓慢地向左滑动第二个项目,同时我的手指仍在触摸屏幕。在开始打开时(BaseSwipeListView中的onStartOpen()),打开的项目很快关闭。当打开的门开始关上时,我停止了移动手指。结果,第二个项目停止在那里。结果如下: 同时,我的布局是: <com.fortysevendeg.
<com.fortysevendeg.swipelistview.SwipeListView
android:id="@+id/album_detail_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/album_description_parent"
android:layout_centerHorizontal="true"
android:layout_margin="2dp"
android:background="#ffffff"
android:cacheColorHint="#000000"
android:divider="@drawable/divider_bg"
android:dividerHeight="2dp"
android:drawingCacheQuality="auto"
android:footerDividersEnabled="false"
android:gravity="top|center_horizontal"
android:headerDividersEnabled="false"
app:swipeActionLeft="reveal"
swipe:swipeBackView="@+id/detail_item_back"
swipe:swipeCloseAllItemsWhenMoveList="true"
swipe:swipeDrawableChecked="@drawable/choice_selected"
swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
swipe:swipeFrontView="@+id/detail_item_front"
swipe:swipeMode="left"
swipe:swipeOpenOnLongPress="false" />
是的,SwipeListView可以通过closeOpenedItems()关闭所有打开的项目。但当有半开的物品时,SwipeListView如何处理?这是SwipeListView中的一个bug吗?是的,它确实是一个bug。听众只听打开或关闭的动作,包括打开开始、打开打开、关闭开始和关闭打开。但是在刷卡的过程中,我们什么也做不了,除了onMove,在onMove中我们可以得到x和y。真可惜 补充: 最终,我找到了这个bug的解决方案。我修改了名为closeAnimate的函数的实现。在349号线。修改后的closeAnimate(int)如下所示:
protected void closeAnimate(int position) {
View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
if (view != null) {
closeAnimate(view.findViewById(swipeFrontView), position);
}
}
终于解决了。在快速垂直滚动期间不会再次发生崩溃
PS:同样的问题发生在openAnimate(int)上,修改的openAnimate(int)如下:
我使用了Android SwipeListView的这个小部件库。我在Github上创建了这个库。我对这个图书馆的问题有了一个解决办法。这是我的,看看吧,仔细看看 我修改了
closeAnimate
的实现。在349号线。修改后的closeAnimate(int)
如下:
protected void closeAnimate(int position) {
View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
if (view != null) {
closeAnimate(view.findViewById(swipeFrontView), position);
}
}
然后,在快速垂直滚动期间不会再次发生崩溃
同时,同样的问题也发生在openAnimate(int)
,修改后的openAnimate(int)
如下:
protected void closeAnimate(int position) {
View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
if (view != null) {
closeAnimate(view.findViewById(swipeFrontView), position);
}
}
protected void closeAnimate(int position) {
View view = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition());
if (view != null) {
closeAnimate(view.findViewById(swipeFrontView), position);
}
}
protected void openAnimate(int position) {
final View child = swipeListView.getChildAt(position - swipeListView.getFirstVisiblePosition()).findViewById(swipeFrontView);
if (child != null) {
openAnimate(child, position);
}
}