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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:07:21+00:00 2026-05-24T05:07:21+00:00

I have a strange problem with my checkbox. In my adapter I have a

  • 0

I have a strange problem with my checkbox. In my adapter I have a TextView, an ImageView and a CheckBox. I had implement a button for select all/deselect all and everything works fine. The problem is that when I select one checkbox, if I scroll the list there are and other checkbox selected(the distance between them is 10) and I don’t understand why. Can anyone help me?

Here is my adapter :

public class LazyAdapter extends BaseAdapter {

        private Activity activity;
        private String[] data;
        private String[] nume;
        private LayoutInflater inflater = null;
        public ImageLoader imageLoader;

        public LazyAdapter(Activity a, String[] d, String[] f) {
            activity = a;
            data = d;
            nume = f;
            inflater = (LayoutInflater) activity
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            imageLoader = new ImageLoader(activity.getApplicationContext(),"Folder2");
        }

        public int getCount() {
            return data.length;
        }

        public Object getItem(int position) {
            return position;
        }

        public long getItemId(int position) {
            return position;
        }

        public class ViewHolder {
            public TextView text;
            public ImageView image;
            public CheckBox ck;
        }

        public View getView(int position, View convertView, ViewGroup parent) {
            View vi = convertView;
            ViewHolder holder;
            if (convertView == null) {
                vi = inflater.inflate(R.layout.item, null);
                holder = new ViewHolder();
                holder.text = (TextView) vi.findViewById(R.id.text);
                holder.image = (ImageView) vi.findViewById(R.id.image);
                holder.ck = (CheckBox) vi.findViewById(R.id.chkbox);
                if (flag)
                    holder.ck.setChecked(true);
                else
                    holder.ck.setChecked(false);

                vi.setTag(holder);
            } else
                holder = (ViewHolder) vi.getTag();

            holder.text.setText(nume[position]);
            holder.image.setTag(data[position]);
            imageLoader.DisplayImage(data[position], activity, holder.image);
            return vi;
        }

    }
  • 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-24T05:07:23+00:00Added an answer on May 24, 2026 at 5:07 am

    Views in list are recycled. Your data list may has 100 rows, but ListView has only 10 (these visible) rows. When you scroll, rows are recycled. The last row in ListView goes to the first position or the other way. You have to change the state of these rows.
    You need to keep checkbox state in array, not in views.

    Add

            final List<Boolean> isCheckedList;
    

    initialize it in constructor:

            isCheckedList = new ArrayList<Boolean>();
            for(int i=0;i<myDataLength;i++){
                isCheckedList.add(Boolean.FALSE);
            }
    

    and modify getView:

            holder.ck.setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View v) {
                    isCheckedList.set(position, holder.ck.isChecked());
                }
            });
    

    in place where you fill rows:

            holder.ck.setChecked(isCheckedList.get(position));
    

    To change state of all checkboxes use:

            Collections.fill(isCheckedList, Boolean.FALSE);
            notifyDataSetChanged();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a strange problem. I have never had it before. When I try
I have a strange problem with select on chrome. I want to add a
I have a strange problem using a MapView in Android. It works fine until
I have strange problem on my pc/server. I run query such as Select field1,
I have strange problem with run .exe program in my WebApplication. It works fine
I have a problem styling my form. Everything works fine except the checkboxes. They
I have a strange problem. I read text from a text file replace all
I have a strange problem.This is my form if User is banned, checkbox is
i have strange problem doing reporting: i have numerous clients with different issued invoices.
I have strange problem with receiving data from socket. On client im using air

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.