Reputation: 69
I have a list view showing all the names of the contacts in the phone.
I want, on the click of a button, for check boxes to appear in front of each row in the list view. Tap any single item of a list view once, and a delete button should appear in front of that respective row.
Here is my layout file:
<?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">
<ListView android:layout_height="350dp" android:id="@android:id/list" android:layout_width="fill_parent" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_marginTop="35dp">
</ListView>
<Button android:id="@+id/button1" android:layout_height="35dp" android:text="Button" android:layout_width="70dp" android:layout_alignParentTop="true" android:layout_alignParentLeft="true"></Button>
<TextView android:id="@+id/textView1" android:textAppearance="?android:attr/textAppearanceMedium" android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="Favourites" android:layout_alignParentRight="true" android:layout_toRightOf="@+id/button1" android:layout_alignBottom="@+id/button1" android:layout_alignParentTop="true" android:gravity="center"></TextView>
</RelativeLayout>
I get my text view from this file:
<?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="?android:attr/listPreferredItemHeight"
android:padding="6dip">
<RelativeLayout
android:orientation="vertical"
android:layout_width="0dip"
android:layout_weight="0.96" android:layout_height="73dp">
<TextView
android:id="@+id/textView_name"
android:layout_height="0dip"
android:gravity="center_vertical"
android:layout_weight="1" android:layout_width="218dp"/>
</RelativeLayout>
</LinearLayout>
Upvotes: 0
Views: 312
Reputation: 5407
You have to add the CheckBoxes to your xml-File and make them invisible.
Than add a code snippet in your listViewAdapter's getView
to make the CheckBox Visible or invisible if for example a boolean Variable is false or true.
Now if you change these Variable just call notifyDataSetChanged();
on your Filter Adapter,
Upvotes: 2