我遇到与此用户相同的问题:the other question
但是我的布局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 jar。
有关此的任何提示吗?
答案 0 :(得分: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
有某种关联答案 1 :(得分:2)
swipeListView有2个视图作为“FrontView”&amp;“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>
答案 2 :(得分: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" />