0

我想从这里创建一个带有滑动(正面和背景)的 listView:

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

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

我创建了一个定义行元素的 xml 文件:

<?xml version="1.0" encoding="utf-8"?>



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



    <RelativeLayout 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/front"
            android:tag="front" 
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:background="#ffffff">

            <ImageView
                android:id="@+id/ImageView01"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true" />

            <TextView
                android:id="@+id/TextView01"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignBottom="@+id/ImageView01"
                android:layout_centerHorizontal="true"
                android:textSize="18sp"

                android:textStyle="bold"
                android:inputType="textMultiLine" />

        </RelativeLayout>





    <LinearLayout 
                      android:layout_width="match_parent"
                      android:layout_height="wrap_content"
                      android:orientation="horizontal"
                      android:id="@+id/back"
                      android:background="#e3e3e3"  
                     android:tag="back"
                     android:layout_marginLeft="5dp"
                     android:layout_marginRight="5dp"

                      >

                      <Button
                          android:id="@+id/deleteBtn1"
                          android:layout_width="150dp"
                          android:layout_height="100dp"

                          android:text="Delete" />

                      <Button
                          android:id="@+id/UpdateBtn1"
                          android:layout_width="150dp"
                          android:layout_height="100dp"

                          android:text="Update" />

                  </LinearLayout>    





</FrameLayout>

和列表视图 xml:

<?xml version="1.0" encoding="utf-8"?>

   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/linearLayout1"
        android:orientation="vertical" >

                <EditText android:id="@+id/EditText01"
                                android:layout_height="wrap_content"
                                android:layout_width="fill_parent"
                                android:hint="Search">                               
                </EditText>

    <com.fortysevendeg.android.swipelistview.SwipeListView
        xmlns:swipe="http://schemas.android.com/apk/res-auto"
        android:id="@+id/example_lv_list"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/profile_listview_back"
        android:listSelector="#00000000"
        swipe:swipeActionLeft="dismiss"
        swipe:swipeActionRight="reveal"
        swipe:swipeBackView="@+id/back"
        swipe:swipeCloseAllItemsWhenMoveList="true"
        swipe:swipeFrontView="@+id/front"
        swipe:swipeMode="both" />

    </LinearLayout>

但是,当我运行此列表视图时,它会向我显示前面的背景(我希望只有在我滑动前面时它才会向我显示背面)

我希望删除和更新按钮仅在滑动前面时显示..

我该如何解决?多谢

在此处输入图像描述

4

1 回答 1

1

在您的行布局中,您应该在 RelativeLayout 之前有 LinearLayout

元素的顺序很重要

<LinearLayout>

  .... buttons ....

</LinearLayout>

<RelativeLayout>

  .... image and text ....

</RelativeLayout>

于 2013-03-22T07:59:52.817 回答