`
rensanning
  • 浏览: 3514450 次
  • 性别: Icon_minigender_1
  • 来自: 大连
博客专栏
Efef1dba-f7dd-3931-8a61-8e1c76c3e39f
使用Titanium Mo...
浏览量:37483
Bbab2146-6e1d-3c50-acd6-c8bae29e307d
Cordova 3.x入门...
浏览量:604351
C08766e7-8a33-3f9b-9155-654af05c3484
常用Java开源Libra...
浏览量:678121
77063fb3-0ee7-3bfa-9c72-2a0234ebf83e
搭建 CentOS 6 服...
浏览量:87298
E40e5e76-1f3b-398e-b6a6-dc9cfbb38156
Spring Boot 入...
浏览量:399823
Abe39461-b089-344f-99fa-cdfbddea0e18
基于Spring Secu...
浏览量:69078
66a41a70-fdf0-3dc9-aa31-19b7e8b24672
MQTT入门
浏览量:90494
社区版块
存档分类
最新评论

Android UI ListView的滑动删除效果之SwipeListView

 
阅读更多
SwipeListView是对ListView的扩展,实现滑动显示删除等操作按钮。

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

***依赖于NineOldAndroids https://github.com/JakeWharton/NineOldAndroids

在layout的布局文件中使用SwipeListView:
<com.fortysevendeg.swipelistview.SwipeListView
            xmlns:swipe="http://schemas.android.com/apk/res-auto"
            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:swipeActionLeft="[reveal | dismiss]"
            swipe:swipeActionRight="[reveal | dismiss]"
            swipe:swipeMode="[none | both | right | left]"
            swipe:swipeCloseAllItemsWhenMoveList="[true | false]"
            swipe:swipeOpenOnLongPress="[true | false]"
            swipe:swipeAnimationTime="[miliseconds]"
            swipe:swipeOffsetLeft="[dimension]"
            swipe:swipeOffsetRight="[dimension]"
            />

  • swipeFrontView - Required - front view id.
  • swipeBackView - Required - back view id.
  • swipeActionLeft - Optional - left swipe action Default: 'reveal'
  • swipeActionRight - Optional - right swipe action Default: 'reveal'
  • swipeMode - Gestures to enable or 'none'. Default: 'both'
  • swipeCloseAllItemsWhenMoveList - Close revealed items on list motion. Default: 'true'
  • swipeOpenOnLongPress - Reveal on long press Default: 'true'
  • swipeAnimationTime - item drop animation time. Default: android configuration
  • swipeOffsetLeft - left offset
  • swipeOffsetRight - right offset


swipeFrontView和swipeBackView必须和list_item.xml中设置的布局ID相同。
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="60dp"
    tools:context=".MainActivity" >

    <LinearLayout
        android:id="@+id/back"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffcccccc"
        android:gravity="center|right" >
        <Button
            android:id="@+id/remove"
            style="@style/button_text"
            android:layout_width="80dp"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:background="@drawable/red_button"
            android:text="Delete" >
        </Button>
    </LinearLayout>

    <LinearLayout
        android:id="@+id/front"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#ffffffff" >
        <TextView
            android:id="@+id/text"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:textSize="25sp"
            android:gravity="center_vertical"
            android:minHeight="?android:attr/listPreferredItemHeight"
            android:textAppearance="?android:attr/textAppearanceLarge" >
        </TextView>
    </LinearLayout>

</FrameLayout>


效果图:


对比微信5的订阅号页面:

  • 大小: 45.6 KB
  • 大小: 90.2 KB
分享到:
评论
7 楼 rensanning 2015-01-12  
错误信息已经提示你了,<com.fortysevendeg.swipelistview.SwipeListView>的属性设置有问题。
引用
java.lang.NumberFormatException: Invalid int: "@2131427497"
6 楼 小黑z 2015-01-11  
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.mo.pmas.activity/org.mo.pmas.activity.ContactGroupActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2333)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2385)
            at android.app.ActivityThread.access$600(ActivityThread.java:157)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:153)
            at android.app.ActivityThread.main(ActivityThread.java:5349)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
            at android.view.LayoutInflater.createView(LayoutInflater.java:683)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:816)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:559)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:419)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:357)
            at android.app.Activity.setContentView(Activity.java:1981)
            at org.mo.pmas.activity.ContactGroupActivity.onCreate(ContactGroupActivity.java:27)
            at android.app.Activity.performCreate(Activity.java:5224)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
            at com.lbe.security.service.core.client.internal.InstrumentationDelegate.callActivityOnCreate(InstrumentationDelegate.java:76)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2385)
            at android.app.ActivityThread.access$600(ActivityThread.java:157)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:153)
            at android.app.ActivityThread.main(ActivityThread.java:5349)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.reflect.InvocationTargetException
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
            at android.view.LayoutInflater.createView(LayoutInflater.java:657)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:816)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:559)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:419)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:357)
            at android.app.Activity.setContentView(Activity.java:1981)
            at org.mo.pmas.activity.ContactGroupActivity.onCreate(ContactGroupActivity.java:27)
            at android.app.Activity.performCreate(Activity.java:5224)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
            at com.lbe.security.service.core.client.internal.InstrumentationDelegate.callActivityOnCreate(InstrumentationDelegate.java:76)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2385)
            at android.app.ActivityThread.access$600(ActivityThread.java:157)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:153)
            at android.app.ActivityThread.main(ActivityThread.java:5349)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
            at dalvik.system.NativeStart.main(Native Method)
     Caused by: java.lang.NumberFormatException: Invalid int: "@2131427497"
            at java.lang.Integer.invalidInt(Integer.java:138)
            at java.lang.Integer.parse(Integer.java:375)
            at java.lang.Integer.parseInt(Integer.java:366)
            at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:123)
            at android.content.res.TypedArray.getInt(TypedArray.java:254)
            at com.fortysevendeg.android.swipelistview.SwipeListView.init(SwipeListView.java:183)
            at com.fortysevendeg.android.swipelistview.SwipeListView.<init>(SwipeListView.java:149)
            at java.lang.reflect.Constructor.constructNative(Native Method)
            at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
            at android.view.LayoutInflater.createView(LayoutInflater.java:657)
            at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:757)
            at android.view.LayoutInflater.rInflate(LayoutInflater.java:816)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:559)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
            at android.view.LayoutInflater.inflate(LayoutInflater.java:419)
            at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:357)
            at android.app.Activity.setContentView(Activity.java:1981)
            at org.mo.pmas.activity.ContactGroupActivity.onCreate(ContactGroupActivity.java:27)
            at android.app.Activity.performCreate(Activity.java:5224)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1081)
            at com.lbe.security.service.core.client.internal.InstrumentationDelegate.callActivityOnCreate(InstrumentationDelegate.java:76)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2297)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2385)
            at android.app.ActivityThread.access$600(ActivityThread.java:157)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1341)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:153)
            at android.app.ActivityThread.main(ActivityThread.java:5349)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:853)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
            at dalvik.system.NativeStart.main(Native Method)
5 楼 小黑z 2015-01-11  
根本就用不了,浪费我时间
4 楼 小黑z 2015-01-11  
Binary XML file line #8: Error inflating class com.fortysevendeg.android.swipelistview.SwipeListView
3 楼 小黑z 2015-01-11  
用不了啊Error:Android Dex: [pmas] com.android.dex.DexException: Multiple dex files define Lcom/nineoldandroids/animation/Animator$AnimatorListener;
2 楼 t1030338120 2014-11-05  
  
1 楼 luolinxi 2014-10-22  
   

相关推荐

Global site tag (gtag.js) - Google Analytics