9

Need help to implement 47degree Android-SwipeListView

Library URL:

https://github.com/47deg/android-swipelistview

Full Fledge Working Example:

https://play.google.com/store/apps/details?id=com.fortysevendeg.android.swipelistview

Problem:

Every time I try to implement swipelistview in my activity listview I get new problems. Lastly I tried to include compiled and distributed JAR (https://oss.sonatype.org/content/groups/public/com/fortysevendeg/android/swipelistview/1.0-SNAPSHOT/) to my project and implement it; it was compiling correctly but when I was trying to run it on the device or avd it was crashing with exception ClassNotFoundException for SwipeListViewTouchListener and many more...

Tool I am using?

Android Studio

What I need?

I would be (and many more developers looking around for same solution ) very grateful if someone can provide very basic example using this library...

  • No need to provide fully working kind of application
  • Demo code with front and back view for listview item working while left and right sliding would be fine
  • No need to implement all settings of the library

The motive of this question is to get idea about how to wire-up 47degree swipelistview library into your application and make it working. Rest things programmer who is using it should be able to find out from API documentation.

Any help on this would be very useful as I am working on one small application where I want to implement such functionality.

4

1 回答 1

16

最后,我设法将 47degree Android-SwipeListView 集成到我自己的应用程序中。

奇迹般有效。感谢 47degree 写出如此精彩的一段代码。

解决方案:

什么不工作!?

将 JAR 作为依赖项和 attrs.xml 包含在 res/values 中,或者将 swipelistview 库作为项目中的 lib 依赖项项目引用都不起作用。

有什么作用!!?

在您的应用程序包中包含以下类。还要将这些类中的包名更正为您的包名

  • SwipeListView.java
  • SwipeListViewListener.java
  • SwipeListViewListenerBase.java
  • SwipeListViewTouchListener.java

将以下 xml 包含到您的应用程序 res/values 文件夹中。

  • attrs.xml

现在您可以按如下方式定义和使用 SwipeListView。

<au.com.your.package.SwipeListView
        xmlns:swipe="http://schemas.android.com/apk/res-auto"
        android:id="@+id/swipe_listview"
        android:listSelector="#00000000"
        android:layout_width="match_parent"
        android:layout_height="match_parent"        
        swipe:swipeFrontView="@+id/front"
        swipe:swipeBackView="@+id/back"
        swipe:swipeActionLeft="reveal"
        swipe:swipeActionRight="choice"
        swipe:swipeMode="both"
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeOpenOnLongPress="true"
        swipe:swipeAnimationTime="100"
        swipe:swipeOffsetLeft="50dp"
        swipe:swipeDrawableChecked="@drawable/item_selected"
        swipe:swipeDrawableUnchecked="@drawable/item_unselected"
   />

您可以使用与 SwipeListView github 站点上的示例中显示的相同的活动代码。

https://github.com/47deg/android-swipelistview-sample/blob/master/src/main/java/com/fortysevendeg/android/swipelistview/sample/activities/SwipeListViewExampleActivity.java

您需要从上面的代码中更正一些导入。

于 2013-11-17T22:30:59.073 回答