Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete selected checkboxes
    primarykey
    data
    text
    <p>I am trying to get the selected checkboxes deleted. I have no clue what to do after this code below: I am using a simple cursor adapter. I also want to know how I could select and deselect all the checkboxes. I had researched everything but can't find any answer. I've been stuck for 3 days. ALso, Im not sure if the code below is even the correct path i need.</p> <pre><code>public class SecondCheckedListView extends ListActivity { private Cursor mCursor; private Long mRowId; DBAdapter db = new DBAdapter(this); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.secondcheckedlistview); db.open(); fillData(); } private void fillData() { mCursor = db.getAllContacts(); startManagingCursor(mCursor); String[] from = new String[]{DBAdapter.KEY_FIRSTNAME, DBAdapter.KEY_LASTNAME}; int[] to = new int[]{R.id.textView1, R.id.textView2}; SimpleCursorAdapter d = new SimpleCursorAdapter(this, R.layout.rowcheckedlistview, mCursor, from, to); setListAdapter(d); } public class MyAdapter extends SimpleCursorAdapter { private final Context mContext; private final int mLayout; private final Cursor mCursor; private final int mNameIndex; private final int mIdIndex; private final LayoutInflater mLayoutInflater; private final class ViewHolder { public TextView firstname; public TextView lastname; public CheckBox cBox; } public MyAdapter(Context context, int layout, Cursor c, String[] from, int[] to) { super(context, layout, c, from, to); this.mContext = context; this.mLayout = layout; this.mCursor = c; this.mNameIndex = mCursor.getColumnIndex(DBAdapter.KEY_FIRSTNAME); this.mIdIndex = mCursor.getColumnIndex(DBAdapter.ROW_ID); this.mLayoutInflater = LayoutInflater.from(mContext); } @Override public View getView(final int pos, View convertView, ViewGroup parent) { if (mCursor.moveToPosition(pos)) { ViewHolder viewHolder; if(convertView == null) { convertView = mLayoutInflater.inflate(mLayout, null); viewHolder = new ViewHolder(); viewHolder.firstname = (TextView) convertView.findViewById(R.id.textView1); viewHolder.lastname = (TextView) convertView.findViewById(R.id.textView2); viewHolder.cBox = (CheckBox) convertView.findViewById(R.id.bcheck); convertView.setTag(viewHolder); }else{ viewHolder = (ViewHolder) convertView.getTag(); } String firstname = mCursor.getString(mNameIndex); String rowId = mCursor.getString(mIdIndex); } return convertView; } } </code></pre> <p>}</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload