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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:31:40+00:00 2026-05-26T12:31:40+00:00

the problem i have is when i click a chekbox and make the listview

  • 0

the problem i have is when i click a chekbox and make the listview scroll-up the selected checkbox change or sometimes if a select the first checkbox so the last checkbox is selected too. I know my English is not good enough yet, sorry about it. Any help appreciated.

import java.util.ArrayList;
import java.util.Hashtable;


import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;

public class MyListAdapter extends BaseAdapter{

     public static class ViewHolder {

         public CheckBox chkb = null;

    } 


    private LayoutInflater mInflater;

    private ArrayList<MyListAdapterItem> myListAdapterItems = null;

    private Hashtable<Object, Object> items = null;

    private boolean selectAll = false;

    private boolean readOnly = false;

    public MyListAdapter(Context context, ArrayList<MyListAdapterItem> myListAdapterItems, boolean selectAll, boolean readOnly) {

        mInflater = LayoutInflater.from(context);

        this.myListAdapterItems = myListAdapterItems;

        this.selectAll = selectAll;

        this.readOnly = readOnly;

        items = new Hashtable<Object, Object>();
    }

    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder viewHolder = null;

        if (convertView == null) {

            convertView = mInflater.inflate(R.layout.chkb_fila, null);

            viewHolder = new ViewHolder();

            viewHolder.chkb = (CheckBox) convertView.findViewById(R.id.chkbCultivo);

            convertView.setTag(viewHolder);

        }else {

            viewHolder = (ViewHolder) convertView.getTag();

        }

        items.put(myListAdapterItems.get(position), viewHolder.chkb);

        viewHolder.chkb.setText(myListAdapterItems.get(position).getDescription());

        if(selectAll){

            viewHolder.chkb.setChecked(true);
        }

        if(readOnly){

            viewHolder.chkb.setEnabled(false);

        }

        return convertView;

    }


    public int getCount() {

        return myListAdapterItems.size();

    }


    public Object getItem(int position) {

        return myListAdapterItems.get(position);

    }


    public long getItemId(int position) {

        return position;

    }

    /**
     * @return the myListItems
     */
    public ArrayList<MyListAdapterItem> getMySelectedListItems() {

        ArrayList<MyListAdapterItem> listSelectedItems = new ArrayList<MyListAdapterItem>();

        CheckBox tmpCheckBox = null;

        for(int i=0; i<items.size(); i++){

            tmpCheckBox = (CheckBox) items.get(myListAdapterItems.get(i));

            if(tmpCheckBox.isChecked()){

                listSelectedItems.add(myListAdapterItems.get(i));

            }

        }

        return listSelectedItems;

    }

}
  • 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-26T12:31:40+00:00Added an answer on May 26, 2026 at 12:31 pm

    Problem is that getView method reuses the views, thus you must make sure to update the checkboxs’ states inside that method; that also implies that you must save that state somewhere.

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

Sidebar

Related Questions

Reproduce problem: run code click checkbox click on the first input box enter: 100
I have a problem when assigning functions to the click event of a button
I have a problem with an animation in jQuery using ajax. On the click
I have a problem... In my view i have Image.If i click on image
i have this annoying problem with my site where, when you click on a
I have a list showing up when I click on button, the problem is
I have problem removing rows from a table according to the checkbox. Below is
I have a checkbox in GridViewColumn which i use for show/change database value. The
I have a ListView with a CheckBox as one of the columns, bound to
Problem: I have an address field from an Access database which has been converted

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.