Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no small snippet ans. to your problem. I assume you need to have multi-selection. Now here are the things you need.</p> <p>Since you are using <code>SimpleCursorAdapter</code>, you should replace that with <code>CursorAdapter</code>. To do so you have to extend it as it is a abstract adapter. Once you done that you will be overriding two functions.</p> <ul> <li><code>newView</code> Where you will create your list item views by inflating <code>R.layout.alarm_row</code> (it should contain your toggle button too). You have make toggle button non-clickable.</li> <li><code>bindView</code> where you will set state of toggle button and text for your text view</li> </ul> <p>That said this what you need on the Activity side.</p> <ul> <li>You have make your ListView to multi-selection mode by <code>android:choiceMode</code> in xml or using <code>setChoiceMode</code>.</li> </ul> <p>Now <code>bindView</code> will look like:</p> <pre><code>ListView lv = ((ListActivity)context).getListView(); // Containing all check states SparseBooleanArray sba = lv.getCheckedItemPositions(); // I am using check box cb.setChecked(false); // Cursor is passed as an argument. if(sba != null) if(sba.get(cursor.getPosition())) cb.setChecked(true); </code></pre> <p>Ref to docs:</p> <p><a href="http://developer.android.com/reference/android/widget/CursorAdapter.html" rel="nofollow">http://developer.android.com/reference/android/widget/CursorAdapter.html</a> http://developer.android.com/reference/android/widget/ListView.html</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