Nikhil Agrawal
Nikhil Agrawal

Reputation: 26518

Implementing 47degree android-swipelistview for swiping android ListViewItem

Actually my goal is to implement a ListViewItem Swipe in android. I have tried it and stackoverflow has several examples which can make your ListViewSwipe. Examples.

Simple swipe gesture to activity tutorial?

Show button in a list view on swiping one item from that list

One point is there everyone is giving the code no one is explaining what is happening.

Then I asked question for it Android list view Right / Left swipes like call logs on which @CommonsWare have answered with SwipeListView library which has a smooth flow then the accepted answer. The accepted answer is also working fine I am presently using that only.

This is the library http://www.androidviews.net/2013/03/swipelistview/ Which provides you listview like this

enter image description here

I have tried more then 50 times to run the sample application provided on github here https://github.com/47deg/android-swipelistview-sample But everytime I am facing new problems. Presently the exception which is coming is

05-22 15:35:19.392: E/AndroidRuntime(980): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.fortysevendeg.android.swipelistview.SwipeListView" on path: /data/app/com.fortysevendeg.android.swipelistview-2.apk

I don't know what is happening I have checked the buildpath, libraries are also included asked so many people on stackoverflow chat But haven't got any help.

Actually on internet there is not a single tutorial for its implementation I have asked to so many peoples. So I want to know if someone have used this library please write an appropriate answer How to use it preporly So with me other future readers can also take the benefit out of it.

Or is there any other library to perform to implement this kind of functionality.

As @CommonsWare suggested. I have written an email to the author also to write an tutorial for using it.

Upvotes: 10

Views: 9605

Answers (4)

Leonardo Costa
Leonardo Costa

Reputation: 1014

I had this same problem.

java.lang.ClassNotFoundException: Didn't find class "com.fortysevendeg.android.swipelistview.SwipeListView"

To solve this you need import the library in Properties > Android > Library > Add... The solution of GDroid didn't work for me.

Tip 1: Copy the library to same workspace or folder of your project, the eclipse was with problem to import the project library in other folder. This post helped me to solve this problem: https://stackoverflow.com/a/5167294/2554730

Tip 2: If you're looking for project library to ecplise, because the project to Android Studio does not works, then try open the project library in Android Studio, after finish the operations you must go at the project's folder and look for

gen-external-apklibs > com.fortysevendeg.android_swipelistview_1.0-20130701.103547-12

This is the folder with the project for eclipse. Import this project and then paste into the folder libs (if there isn't libs folder... create one) the

android-support-v4.jar and nineoldandroids-2.4.0.jar

These .jars should fix your errors.

Upvotes: 0

Slampy
Slampy

Reputation: 326

Try to add the following to build.grandle

repositories {
    mavenCentral()
    flatDir {
        dirs 'libs'
    }
    maven { url 'http://clinker.47deg.com/nexus/content/groups/public' }
}

Upvotes: 0

GDroid
GDroid

Reputation: 1344

Finally, I've managed to integrate Android-SwipeListView library by 47Degrees into my own application.

Works like a charm. Thanks to 47Degrees for writing such a wonderful piece of code.

Solution:

What doesn't work?!

Including JAR as dependency and attrs.xml in res/values OR referencing the SwipeListView library as a lib dependency in your project does not work.

What works?!

Include following classes in your application package. Be sure to correct the package names in these classes to your package name

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

Include following xml into your application res/values folder

  • attrs.xml

Now you can define and use SwipeListView as follows

<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"
   />

Activity code you can use same as displayed in the example on SwipeListView github site.

You will need to correct some imports from the code above. In addition, you'll need to have NineOldAndroids by Jake Wharton included as a lib dependency in your project.

Upvotes: 12

DArkO
DArkO

Reputation: 16110

The simplest test is to copy the whole thing inside your project. I see that it only has attr.xml in resources so it wont be that hard to do nor it will make your project dirty. Try that. Just copy/paste straight to /src

This should be a Android Library project and you should attach it as such. The bug you are having sometimes happens for some stupid reason which i don't know when you add libraries inside /libs (doesn't need referencing in BuildPath that way).

In this specific case this project will work only if you connect it as a library project, not a JAR.

Hope this helps.

Also this library is a Maven project. you need to have maven for android setup to be able to build it. or convert it back to a regular project.

Upvotes: 2

Related Questions