Skip to content

Commit ff93708

Browse files
author
Mattias Flodin
committed
Examples in demo project for checkable listviews with removable items
1 parent ea7e153 commit ff93708

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

demo/res/layout/list_item_checkable.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,10 @@
1919
android:textAppearance="?android:attr/textAppearanceMedium"
2020
android:gravity="center_vertical"
2121
android:paddingLeft="8dp" />
22+
<ImageView
23+
android:id="@id/click_remove"
24+
android:background="@drawable/delete_x"
25+
android:layout_width="@dimen/item_height"
26+
android:layout_height="@dimen/item_height"
27+
android:layout_weight="0" />
2228
</com.mobeta.android.demodslv.CheckableLinearLayout>

demo/src/com/mobeta/android/demodslv/MultipleChoiceListView.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import android.widget.ArrayAdapter;
99

1010
import com.mobeta.android.dslv.DragSortListView;
11+
import com.mobeta.android.dslv.DragSortListView.RemoveListener;
1112

1213

1314
public class MultipleChoiceListView extends ListActivity
@@ -28,6 +29,17 @@ public void drop(int from, int to) {
2829
}
2930
};
3031

32+
private RemoveListener onRemove =
33+
new DragSortListView.RemoveListener() {
34+
@Override
35+
public void remove(int which) {
36+
DragSortListView list = getListView();
37+
String item = adapter.getItem(which);
38+
adapter.remove(item);
39+
list.removeCheckState(which);
40+
}
41+
};
42+
3143
@Override
3244
protected void onCreate(Bundle savedInstanceState) {
3345
super.onCreate(savedInstanceState);
@@ -42,6 +54,7 @@ protected void onCreate(Bundle savedInstanceState) {
4254

4355
DragSortListView list = getListView();
4456
list.setDropListener(onDrop);
57+
list.setRemoveListener(onRemove);
4558
}
4659

4760
@Override

0 commit comments

Comments
 (0)