2013-04-15 76 views
2

我有同樣的問題,這個用戶:the other question安卓swipelist缺少的屬性

但是我對我的佈局XML文件中的類鍵入正確的名稱,在XML查看它不給任何錯誤,但當我更改爲圖形佈局視圖時,出現錯誤消息:

java.lang.RuntimeException: You forgot the attributes swipeFrontView or swipeBackView. 
You can add this attributes or use 'swipelist_frontview' and 'swipelist_backview'  
identifiers 

我添加了nineoldandroid和滑動列表罐。

對此有何祕訣?

回答

0

你需要在你列出這樣的事情:

<?xml version="1.0" encoding="utf-8"?> 
<com.fortysevendeg.android.swipelistview.SwipeListView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:swipe="http://schemas.android.com/apk/res-auto" 
    android:id="@android:id/list" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:listSelector="#00000000" 
    swipe:swipeActionLeft="dismiss" 
    swipe:swipeBackView="@+id/back" 
    swipe:swipeCloseAllItemsWhenMoveList="true" 
    swipe:swipeFrontView="@+id/front" 
    swipe:swipeMode="both" /> 
2

改變SwipeListView的ID,以

swipe:swipeBackView="@+id/swipelist_backview" 
swipe:swipeFrontView="@+id/swipelist_frontview" 

並在列表項以

<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:id="@+id/swipelist_backview" 
     ...> 
     ... 
    </RelativeLayout> 

    <RelativeLayout 
     android:id="@+id/swipelist_frontview" 
     ...> 
     ... 
    </RelativeLayout> 

    </FrameLayout> 

爲我解決了這個問題。我認爲,這個錯誤是某種與此相關的上拉要求https://github.com/47deg/android-swipelistview/pull/11

2

swipeListView有2次爲 「FrontView的」 & 「BackView」 試試這個示例XML:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent"> 

<RelativeLayout 
     android:id="@+id/back" 
     style="@style/ListBackContent" 
     android:layout_width="wrap_content" 
     android:layout_height="110dp" 
     android:tag="back" > 

    <LinearLayout 
      android:id="@+id/backshowportion" 
      style="@style/ListBackContent" 
      android:layout_width="250dp" 
      android:layout_height="110dp" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentTop="true"   
      android:gravity="right|center" > 

      <TextView 
        .... /> 

      <TextView 
        .... /> 

      <TextView 
         ..../> 
    </LinearLayout> 

</RelativeLayout> 

<RelativeLayout 
     android:id="@+id/front" 
     style="@style/ListFrontContent" 
     android:layout_width="match_parent" 
     android:layout_height="110dp" 
     android:orientation="vertical" 
     android:tag="front" > 
     <TextView 
       .... /> 

     <TextView 
       .... /> 

     <TextView 
       .... /> 

</RelativeLayout> 

</FrameLayout>