title: Android ListView With Check Box Deleting/Getting Row ID
body: <p>I am trying to implement a listview with checkbox so that when a check box is checked the list row will be removed. I am populating the listview with a cursor and this is working fine and the checkbox is being displayed. </p>
  
  <p>What I am having trouble with is figure out how to get the _id of the row of the box that has been checked. </p>
  
  <p>Can anyone show me how to implement something like this </p>
  
  <p><strong>ListView and CheckBox</strong></p>
  
  <pre><code>        Cursor cursor = db.getAllItems();
  
      //String[] columns = new String[] {db.KEY_NAME, db.KEY_CODE, db.KEY_ROWID};
      String[] columns = new String[] {db.KEY_ITEM_NAME, db.KEY_MEASUREMENT, db.KEY_UNIT};
  
      int[] to = new int[] {R.id.ingredientName, R.id.ingredientMeasurement, R.id.ingredientUnit};
  
      final SimpleCursorAdapter myCursorAdapter = new SimpleCursorAdapter(this,R.layout.row4, cursor, columns, to, 0);
  
      final ListView shoppingList = (ListView) findViewById(R.id.shoppingList);
      shoppingList.setAdapter(myCursorAdapter);
  
  
      CheckBox deleteCheck = (CheckBox)findViewById(R.id.checkBox1);
  
      deleteCheck.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(RadioGroup group, int checkedId) {
              if (isChecked){
                  // How do I get the list item clicked to delete row?
              }
          }
  
      });
  </code></pre>
  
  <p><strong>XML - Row.4.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="horizontal"
  android:weightSum="1"&gt;
  
  &lt;TextView
      android:id="@+id/ingredientName"
      android:layout_width="wrap_content"
      android:textColor="#000000"
      android:layout_height="wrap_content"
      android:padding="5dp"
      android:hint="wewewe"/&gt;
  
  &lt;TextView
      android:id="@+id/ingredientMeasurement"
      android:textColor="#000000"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toRightOf="@+id/ingredientName"
      android:padding="5dp"
      android:hint="fefefef"/&gt;
  
  &lt;TextView
      android:id="@+id/ingredientUnit"
      android:textColor="#000000"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_toRightOf="@+id/ingredientMeasurement"
      android:padding="5dp"
      android:hint="qqqqq"/&gt;
  
  
  &lt;CheckBox
      android:id="@+id/checkBox1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_gravity="right"
      android:background="#fff"
      android:text=""/&gt;
  &lt;/LinearLayout&gt;
  </code></pre>