2

我和这个用户有同样的问题:另一个问题

但是我在我的布局 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 和 swipe-list jars。

对此有什么建议吗?

4

3 回答 3

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

于 2013-06-26T11:45:50.490 回答
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>
于 2013-11-20T12:19:19.523 回答
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" />
于 2013-06-21T22:36:38.127 回答