1.导依赖
compile 'com.yanzhenjie:recyclerview-swipe:1.1.4'
2.xml控件
<com.yanzhenjie.recyclerview.swipe.SwipeMenuRecyclerView android:id="@+id/cmm_recyc" android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" />
3.适配器的方法
private void initAdapter() { LinearLayoutManager manager = new LinearLayoutManager(this); cmmRecyc.setLayoutManager(manager); //添加item分割线---------------------设置分割线颜色为灰色 // cmmRecyc.addItemDecoration(new DefaultItemDecoration(MyApplication.getInstace().getResources().getColor(R.color.gray))); defaultItemDecoration = new DefaultItemDecoration(MyApplication.getInstace().getResources().getColor(R.color.gray)); // 假如第一条分割线都是空,那么就表示是第一次进入,假如第一条分割线不为空,表示已经有分割线 if (itemDecorati