Show button in a list view on swiping one item from that list

。_饼干妹妹 提交于 2019-12-12 04:34:31

问题


I am working on an android application and I want to show a button when user swipe a particular item of list.

Here is my xaml in which I have a button and few other items. I am using this xml in my list view:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent" android:background="#f1eff0">


    <TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" android:layout_height="wrap_content"
        android:visibility="visible" android:id="@+id/tb1">

        <TableRow>
            <TextView android:id="@+id/createdBy" android:typeface="normal" 
                android:singleLine="true" android:textSize="14sp" android:textStyle="bold"
                android:layout_width="wrap_content" android:textColor="#000000"
                android:layout_height="wrap_content" />
        </TableRow>
        <TableRow>
            <TextView android:id="@+id/postText" android:typeface="normal"
                android:singleLine="true" android:textSize="14sp" android:textStyle="normal"
                android:layout_width="wrap_content" android:textColor="#000000"
                android:layout_height="wrap_content" />
                <Button android:id="@+id/btnDelete" android:textColor="#ffffff" android:visible="Gone"
                android:background="@color/hover_button" android:text="Delete"
                android:textSize="14sp" android:textStyle="normal" android:typeface="normal"
                android:layout_marginLeft="320dp" />
        </TableRow>
        <TableRow>
            <TextView android:id="@+id/postDate" android:typeface="normal"
                android:singleLine="true" android:textSize="14sp" android:textStyle="normal"
                android:layout_width="wrap_content" android:textColor="#000000"
                android:layout_height="wrap_content" />
        </TableRow>
    </TableLayout>
</RelativeLayout>

I have already searched on google but could not understand the examples I am new for android please help me.


回答1:


The following link will help you in implementing the swipe delete action in the listview.

Swipe delete operation in listview




回答2:


I would suggest you to implement 47Degree Swipe List View (Works ultimate)

Get more information on implementing Swipe List View here,

Slide ListView Item on Android like iPhone Mail app

Need help to implement 47degree Android-SwipeListView

Accept & up-vote answers if you find them useful.



来源:https://stackoverflow.com/questions/12858635/show-button-in-a-list-view-on-swiping-one-item-from-that-list

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!