mardi 6 décembre 2016

Add checkbox to ListView while keeping onListItemClick

I currently have an SQLite3 database that a user saves their data to through an EditText. A ListView is then used to display the date the EditText data was saved. Upon clicking the date in the ListView, the data the user saved is then presented.

I would like to add functionality that would allow a checkbox to be added to each ListView item that would indicate that the user would like to delete that datapoint.

What would be the best way to have a checkbox that can allow for the inclusion of a "delete" button, but also maintain the function that when a ListView item is clicked, it shows previously saved data?

I have previously tried:

ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(
            this,
            android.R.layout.simple_list_item_multiple_choice,
            arrayDateList);
setListAdapter(arrayAdapter);

But each time the item is clicked, it shows the previous item and selects the checkbox. I would like only to select the checkbox, or the list item, but not both. Would this also mean a change in the XML file, too?

Thanks in advance!




Aucun commentaire:

Enregistrer un commentaire