# SwipeCardView **Repository Path**: HarmonyOS-tpc/SwipeCardView ## Basic Information - **Project Name**: SwipeCardView - **Description**: 自定义卡片,左右飞滑删除卡片,上下滑卡片回弹复位。 - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 0 - **Created**: 2021-04-15 - **Last Updated**: 2023-04-17 ## Categories & Tags **Categories**: harmonyos-view-transition **Tags**: None ## README # SwipeCardView **本项目基于开源项目SwipeCardView进行鸿蒙化的移植和开发,可以通过项目标签以及github地址(https://github.com/xiepeijie/SwipeCardView)追踪到原安卓项目版本** #### 项目介绍 自定义卡片,左右飞滑删除卡片,上下滑卡片回弹复位。 #### 集成 ``` 方式一: 添加har包到entry模块libs文件夹 在entry的gradle内添加如下代码: implementation fileTree(dir: 'libs', include: ['.jar', '.har']) 方式二: allprojects { repositories { mavenCentral() } } implementation 'io.openharmony.tpc.thirdlib:SwipeCardView:1.0.1' ``` #### 使用教程 1、xml布局里添加SwipeFlingAdapterView ``` ``` 2、Ability中添加 ``` swipeView = (SwipeFlingAdapterView) findViewById(R.id.swipe_view); swipeView.setIsNeedSwipe(true);// 是否开启swipe滑动效果,当不调用此方法设置时,默认开启。 swipeView.setFlingListener(this); swipeView.setOnItemClickListener(this); ``` **onFlingListener** ``` @Override public void removeFirstObjectInAdapter() { adapter.remove(0); } @Override public void onLeftCardExit(Object dataObject) { // to do something } @Override public void onRightCardExit(Object dataObject) { // to do something } @Override public void onAdapterAboutToEmpty(int itemsInAdapter) { if (itemsInAdapter == 3) { loadData(); } } ``` **Click to swipe** ``` @Override public void onClick(View v) { // swipe left swipeView.swipeLeft(); // swipe right //swipeView.swipeRight(); } ```