Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3978866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T05:06:00+00:00 2026-05-20T05:06:00+00:00

I am using checkbox with ListView.Code is working fine. I strucked to get all

  • 0

I am using checkbox with ListView.Code is working fine. I strucked to get all the list checked Items. I used below code for getting checked items. But it is giving result of focused area of list.

int firstPosition = list.getFirstVisiblePosition();

        for(int i = firstPosition; i < list.getCount(); i++){
            View v = list.getChildAt(i);
            if(v != null){
                cbx = (CheckBox)v.findViewById(R.id.c_checkbox);
                if(cbx.isChecked()){
                                        //adding this check box to one sub list
                }
            }
        }

But it is giving only focusable list items result only.Depending on sublist I want to populate my menu that’s why I am using this code in onPrepareOptionsMen() method and clicking on menu item delete this list from database.
I found another solution that is

long checkedPos[] =list.getCheckedItemIds();

But it is giving

01-31 12:07:16.042:
WARN/dalvikvm(294): VFY: unable to
resolve virtual method 808:
Landroid/widget/ListView;.getCheckedItemIds
()[J 01-31 12:07:16.042:
WARN/dalvikvm(294): VFY: rejecting
opcode 0x6e at 0x0024

This error. After searching on Google I found another solution that is

http://groups.google.com/group/android-developers/browse_thread/thread/368d0bae027aab63/1c61f007e821ed2a?q=%22Getting+the+state+of+a+checkbox+inside+of+a+listview%22+%22Romain+Guy%22#1c61f007e821ed2a

but I want to use SparseBooleanArray into my activity onPrepareOptionMenu().How to get back this result into my activity from my adapter.Please give me advice?

At last i used SparseBooleanArray.Now it is working fine.
Regards,
Android developer

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T05:06:01+00:00Added an answer on May 20, 2026 at 5:06 am

    By using SparseBooleanArray in my custom adapter, solved this problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using listview in which each item (of list view) has a checkbox
Using the following to populate my ListView with checkbox-supported list: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, new
Hi i am using the following code to generate a custom listview with checkbox.how
i am trying to get checkbox value ,using c# In grid view the datasource
I've got a ListView with a custom BaseAdapter. The list items contain CheckBoxes that
I am using a Listview in a usercontrol that I databind to a list
i have a listview with checkbox in each rows. i'm using custom cursoradapter and
So I have a custom ListView object. The list items have two textviews stacked
I'm trying to implement a list using the ListView, which contains rows built with
Using Listview with Checkbox ListView checkbox id 001 002 003 ... I want to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.