1. 程式人生 > >關於android-swipelistview的開源專案的使用

關於android-swipelistview的開源專案的使用

android-swipelistview開源專案將列表升級到了一個新的高度,用起來非常帥,微信5.0也採用了這種方式,先上效果圖:

不得不佩服這些牛人啊,下面介紹如何使用這個專案,專案在github上:https://github.com/47deg/android-swipelistview-sample

專案分為兩部分,一部分是庫(要依賴nineoldandroids-2.4.0.jar),另外一部分是一個測試程式,很多人在匯入的時候會有各種各樣的錯誤,

具體匯入步驟可以看看這位朋友的,很詳細:http://blog.csdn.net/zhangxinrun/article/details/8965115

我沒有按照那些步驟來,我的做法如下:

1. 將android-swipelistview-master資料夾下的swipelistview-samples工程匯入eclipse中,並且新建一個包com.fortysevendeg.android.swipelistview.listview,具體可參考上面網址中的步驟;

2.將swipelistview資料夾中的src目錄下的4個java檔案(swipelistview\src\com\fortysevendeg\swipelistview)拷貝到swipelistview-samples工程中;

3.將swipelistview資料夾中res\values目錄下的swipelistview__attrs.xml檔案拷貝到工程的values目錄下;

4.匯入nineoldandroids-2.4.0.jar和android-support-v4.jar包;

5.clean工程,匯入相關類、修復包名,沒有錯誤,執行程式,又有新的錯誤,原因是引用SwipeListView的路徑不對;

6.在swipe_list_view_activity.xml檔案中,如下紅色標示:

<com.fortysevendeg.android.swipelistview.listview.SwipeListView
            android:id="@+id/example_lv_list"
            android:listSelector="#00000000"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            swipe:swipeFrontView="@+id/front"
            swipe:swipeBackView="@+id/back"
            swipe:swipeDrawableChecked="@drawable/choice_selected"
            swipe:swipeDrawableUnchecked="@drawable/choice_unselected"
            swipe:swipeCloseAllItemsWhenMoveList="true"
            swipe:swipeMode="both"
            />
這樣可以正常運行了,具體原始碼大家可以研究下,附上除錯好了的工程demo:

http://download.csdn.net/detail/yuyan19850204/6506461