Note that there are some explanatory texts on larger screens.

plurals
  1. POMultiple selection in custom ListView with CAB
    primarykey
    data
    text
    <p>After reading and try'n'error for days, I´m giving up and ask for help.</p> <p>&lt; edit > I am using ActionBarSherlock. &lt; /edit ></p> <p><strong>What I want to achieve:</strong> A ListView with a custom layout for each row, where the user can select multiple list items. A selected list item should have a different background color. When there is at least one item selected, a contextual action bar (CAB) should be shown. It should look more or less like the multiple selection of emails in the GMail app. The only difference is that in the gmail app the selection is done by clicking the checkbox of a row, whereas I don´t want to have a checkbox, but a row should be selected no matter, where the user clicks. <img src="https://i.stack.imgur.com/hsfUm.png" alt="Multiple selection in GMail app"></p> <p><strong>What I tried:</strong> Following <a href="http://www.marvinlabs.com/2010/10/custom-listview-ability-check-items/" rel="nofollow noreferrer">this tutorial</a>, using a Checkable row layout with some logic to change the background color when the check state was toggled, I got everything working except that I could not register a click listener like OnItemClickListener on the ListView to show the CAB. Neither providing a click listener for each row View helped because this prevented to change the background color of the selected items. I also tried adding a MultiChoiceModeListener to the ListView like that</p> <pre><code> listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); listView.setMultiChoiceModeListener(new MultiChoiceModeListener() { //.. }); </code></pre> <p>With the same result, no background color change.</p> <p><strong>What I am looking for</strong>: A hint or a tutorial or sample code how to do this. If you need some code snippets to help, let me know.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    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