Android 滑动删除库:RecyclerViewSwipeDismiss

jopen 9年前

非常易于使用的滑动删除库,用于Android的RecyclerView,支持水平方向和竖直方向的滑动删除。

如何使用

  • Add these lines to yourbuild.gradle
repositories {      maven {          url "https://jitpack.io"      }  }    dependencies {       compile 'com.github.CodeFalling:RecyclerViewSwipeDismiss:v1.1.1'  }

  • BuildonTouchListenerand bind it to yourRecyclerView
SwipeDismissRecyclerViewTouchListener listener = new SwipeDismissRecyclerViewTouchListener.Builder(          recyclerView,          new SwipeDismissRecyclerViewTouchListener.DismissCallbacks() {              @Override              public boolean canDismiss(int position) {                  return true;              }                @Override              public void onDismiss(View view) {                  // Do what you want when dismiss                }          })          .setIsVertical(false)          .setItemTouchCallback(                  new SwipeDismissRecyclerViewTouchListener.OnItemTouchCallBack() {                      @Override                      public void onTouch(int index) {                          // Do what you want when item be touched                      }                  })          .create();  recyclerView.setOnTouchListener(listener);

More

  • setIsVertical(false)means allow swipe in horizontal direction

  • listener.setEnabled(false)can disable swipe to dismiss

  • onTouchwill be called when MOUSE_UP on item without swipe

Android 滑动删除库:RecyclerViewSwipeDismiss

项目主页:http://www.open-open.com/lib/view/home/1445773975085