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 8308177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:43:17+00:00 2026-06-08T18:43:17+00:00

I am using ListView with CheckBox . I have selected only one CheckBox but

  • 0

I am using ListView with CheckBox. I have selected only one CheckBox but it’s automatically selected into Multiple Rows using ScrollView.

Sample Code (This Code is working Perfectly)

       holder.checkbox.setOnClickListener( new OnClickListener()
        {
            public void onClick( View v )
            {
                CheckBox cb = ( CheckBox ) v;
                if ( cb.isChecked() )
                {
                    test[position] = true;
                    holder.checkbox.setChecked(test[position]);
                }
                else
                {
                    test[position] = false;
                    holder.checkbox.setChecked(test[position]);
                }
            }
        });
        holder.checkbox.setChecked(test[position]);

But When i uses setOnItemClickListener it’s not working.

Sample Code (This code is not working for me)

        listview.setOnItemClickListener( new OnItemClickListener() 
        {
            public void onItemClick( AdapterView<?> parent, final View v, final int position, long id ) 
            {
                holder.checkbox = ( CheckBox ) v.findViewById( R.id.lock_File_CheckBox );
                if ( holder.checkbox.isChecked() )
                {
                    test[position] = false;
                    holder.checkbox.setChecked(test[position]);
                }
                else
                {
                    test[position] = true;
                    holder.checkbox.setChecked(test[position]);
                }
            }
        });
        holder.checkbox.setChecked(test[position]);

Where i can mistaken. How do avoid this CheckBox Selection.

Can you please help me?

  • 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-06-08T18:43:18+00:00Added an answer on June 8, 2026 at 6:43 pm

    You can get the instance of CheckBox inside onItemClick() by using setTag() and getTag(). You can setTag the CheckBox instance inside your getView() method as

    convertView.setTag(R.id.check, viewHolder.checkbox);
    

    And get the instance inside onItemClick() using,

    CheckBox checkbox = (CheckBox) v.getTag(R.id.check);
    

    If you have any further query you can check my blog post.

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

Sidebar

Related Questions

i have a listview with checkbox in each rows. i'm using custom cursoradapter and
I have an Android ListView with rows that include one checkbox, and four text
I have a ListView ,checkbox and spinner in one layout , and on different
I want to save the state of a multiple choice listview checkbox's. I have
I am using checkbox with ListView.Code is working fine. I strucked to get all
I created one checkbox and one textfield for each line using wicket listview. When
I have created listview using layoutinflator. Listview contains checkbox and textview for each row.
i want to make a tri-state checkbox inside listview control, iam using image list
What are the advantages of using listview over gridview? I need pagination, editing rows,
How do I do pagination using ListView. For an example, I have 12 records

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.