Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 534
Nikhil Agrawal Avatar asked May 22 '13 10:05

Nikhil Agrawal


1 Answers

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.

like image 75
GDroid Avatar answered Oct 05 '22 23:10

GDroid