maintaining the state of checkboxes on android listviews

Posted on 2012-09-11
Last Modified: 2012-09-17
Hello Experts,

I am using a listview with checkboxes.

I manually set the the checkboxes.

I want to pre-set the checkboxes again when I come back to the listview.

Please can you give me the command to programatically set the checkboxes when the listview is re-loaded (I know how to store the details of the checkboxes that were checked).

Many Thanks!
Question by:jagku
    LVL 13

    Expert Comment

    by:Molnar István

    Author Comment

    Thank you.  However, I would like to clarify that I am trying to set the checkboxes that come with a listview. (They are not checkboxes that i have created in a layoutfile)
    LVL 8

    Expert Comment

    Hi jagku,

    Use the
    SparseBooleanArray sparseBooleanArray = myList.getCheckedItemPositions();

    This method will return the selected state  of the ListView.

    Refer this link for some samples...


    Accepted Solution


    Thank you for all your responses.
    Unfortunately, this hasn't answered the query.

    To get this working, I by creating a custom adaptor.


    Author Closing Comment

    See above answer

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    I recently asked a question ( about Computer Inventory applications for Mobile Devices.  I was specifically interested in an app I could use on my android phone.  The be…
    A short article about a problem I had getting the GPS LocationListener working.
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now