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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:03:13+00:00 2026-05-26T04:03:13+00:00

hi i am using checkboxes with listview in android when i am scrolling listitem

  • 0

hi i am using checkboxes with listview in android when i am scrolling listitem i am not getting the same checkboxes checked what are expected please help me in figuring out where i am wrong. when i select frst check box and scroll its give me second checkbox as checked and other output are also strange.here is my code

class base extends BaseAdapter{

        @Override
        public int getCount() {
            // TODO Auto-generated method stub
            return price.size();
        }

        @Override
        public Object getItem(int arg0) {
            // TODO Auto-generated method stub
            return arg0;
        }

        @Override
        public long getItemId(int arg0) {
            // TODO Auto-generated method stub
            return arg0;
        }

        @Override
        public View getView(int arg0, View arg1, ViewGroup arg2) {
            // TODO Auto-generated method stub
            View v=arg1;
j=arg0;
            LayoutInflater li=getLayoutInflater();
            v=li.inflate(R.layout.listitem, null);
            TextView txt=(TextView)v.findViewById(R.id.tv_name);
            txt.setText(author.get(arg0));
            TextView txt1=(TextView)v.findViewById(R.id.tv_description);
            txt1.setText(price.get(arg0));
            TextView txt2=(TextView)v.findViewById(R.id.txtv);
        txt2.setText(title.get(arg0));
        ImageView img=(ImageView)v.findViewById(R.id.iv_forward);


        img.setImageBitmap(bit.get(arg0));
        CheckBox check1=(CheckBox)v.findViewById(R.id.check);
        if(check[j]!=null)
            if(check[j]==true)
            check1.setChecked(true);
            else check1.setChecked(false);

        check1.setOnCheckedChangeListener(new OnCheckedChangeListener(){

            @Override
            public void onCheckedChanged(CompoundButton arg0, boolean arg2) {
                // TODO Auto-generated method stub
                if(arg2==true)
                //  Toast.makeText(SimpleActivity.this,arg0+"", Toast.LENGTH_LONG).show();
                check[j]= true;
                else 
                    check[j]=false;
            }

        });

            return v;


    }
        }

please help.

  • 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-26T04:03:14+00:00Added an answer on May 26, 2026 at 4:03 am

    Since you are recycling your views each time, the checkbox will have the same value as the previous view of the listview. What I would do is set the checkbox to false FIRST for every iteration and THEN figure out whether or not it should be checked:

    check1.setChecked(false);
    if(check[j]!=null && check[j]==true){
            check1.setChecked(true);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the following to populate my ListView with checkbox-supported list: setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_checked, new
Here's the scenario conceptually (excluding linearlayouts) ScrollView Button Checkboxes Spinner ListView (full-size, non-scrolling) AdMob
How to pass multiple checkboxes using jQuery ajax post this is the ajax function
I have bound a flagged enum to a bunch of checkboxes by using a
I'm using a column of checkboxes in a YUI DataTable, I works fine. But
I'm using Zend_Form to output a set group of checkboxes: <label style=white-space: nowrap;><input type=checkbox
I'm using jQuery and the minlength method for the validation plugin rules: { checkboxes:
Is there a way to get colored checkboxes like in iCal without using custom
How do I know, using jQuery, if all or none of the following checkboxes
I am using a in-place editable listview control for a project. The editable listview

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.