Checkbox ListView

This small chuck of code saves time and effort if you’re looking for a solution to implementing a ListView that supports Checkboxes.

The end result:

I initialized my list inside onCreate( )
ListView listView1;

// Populate this string array to create ListView items
String[] listItems = { "List Item #1", "List Item #2" };

// Initialize ListView
listView1 = (ListView)findViewById(;
listView1.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice, listItems));

// Check or Uncheck the box onClick
listView1.setOnItemClickListener(new OnItemClickListener() {
   public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
      CheckedTextView ctv = (CheckedTextView)arg1;

      // Any additional stuff to do goes here