Step 1 :
In your custom row use CheckedTextView
instead of TextView
and CheckBox
custom_row.xml
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/chkTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#000000"
android:textSize="14sp"
android:textStyle="bold" />
Step 2:
In your activity
public void onItemClick(AdapterView<?> arg0, View view, int postion, long id) {
hold the selected item position in a array list (depends upon the item is checked or unchecked.)
}
Step 3:
On Clicking of Submit Button persist the selected position in any of the storage technique (most preferable object cache).
Step 4 :
While creating the Activity :
Step 4.1 : Add the below Line
listvw = (ListView)findViewById(android.R.id.list);
listvw.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
Step 4.2 : Get the persisted ids
If it very first time call then the persisted value is null or list size 0.
long[] checkedItemIds = retriveFromPersistence();
if (checkedItemIds != null) {
for(int id_count = 0; id_count < checkedItemIds.length; id_count++) {
listvw.setItemChecked((int) checkedItemIds[id_count], true);
}
}