I am new to programming and have a problem using getCheckedItemPositions()for checkboxes and getting edit values from edit text in a custom list view. Can someone help me with an example of creating a custom list having the above functionality. Thank you
* This is a custom listview xml
<CheckBox android:id="@+id/checkBox" android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentRight="true"
android:text="CheckBox"
android:onClick="clickHandler"
></CheckBox>
<TextView android:layout_height="wrap_content"
android:layout_width="fill_parent" android:text="TextView"
android:id="@+id/textView1"
android:layout_alignParentLeft="true"
android:layout_centerHorizontal="true" android:layout_marginBottom="14dp"
Android: layout_toLeftOf = "@ + id / checkbox">
* This is the code for setting listview
lv1 = (ListView) dialog.findViewById(R.id.l1); adapter2 = SimpleCursorAdapter ( , R.layout.custom, CURSOR2, new String [] { "ItemName" }, new int [] {R.id.textView1});
lv1.setItemsCanFocus(false);
lv1.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
lv1.setAdapter(adapter2);
* , ,
public void onClick (View v) {
int len = lv1.getCount();
SparseBooleanArray checked = lv1.getCheckedItemPositions();
for (int i = 0 ; i < len; i++)
if (checked.get(i)) {
String item = mArrayList.get(i);
mItems.add(mArrayList.get(i));
System.out.println(item);
}
. , . , .
