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

  • Home
  • SEARCH
  • 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 8918625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:48:17+00:00 2026-06-15T05:48:17+00:00

I am trying to check all checkboxes through the custom adapter with one button

  • 0

I am trying to check all checkboxes through the custom adapter with one button click. But when I implement

ArrayList<BazarItems> objects

    public void allChecked(){

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

            cbBuy.setChecked(true);
        }

    }

the only last item is checked.
What am I doing wrong?

have tried this one

`public void checkAll () {

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

            BazarItems b = objects.get(i);

            b.box = true;

            cbBuy.setChecked(b.box);
        }
    }   
    `

here we go. I am probably missing something on custom adapter. In my understanding what I have should be enough to complete task.

`public class BazarListAdapter extends BaseAdapter {

    Context ctx;
    LayoutInflater lInflater;
    ArrayList<BazarItems> objects;

    CheckBox cbBuy;

    BazarListAdapter(Context context, ArrayList<BazarItems> products) {
        ctx = context;
        objects = products;
        lInflater = (LayoutInflater) ctx
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public int getCount() {
        return objects.size();
    }

    public Object getItem(int position) {
        return objects.get(position);
    }

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

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

        View view = convertView;
        if (view == null) {
            view = lInflater.inflate(R.layout.activity_bazar_list_child_item,
                    parent, false);
        }

        BazarItems i = getItems(position);

        ((TextView) view.findViewById(R.id.tvDescription)).setText(i.name);
        ((TextView) view.findViewById(R.id.tvQuantity))
                .setText(i.quantity + "");
        ((TextView) view.findViewById(R.id.tvPrice)).setText(i.price + "");

        cbBuy = (CheckBox) view.findViewById(R.id.checkBox);

        cbBuy.setOnCheckedChangeListener(myCheckChangList);

        cbBuy.setTag(position);

        cbBuy.setChecked(i.box);
        return view;
    }

    BazarItems getItems(int position) {
        return ((BazarItems) getItem(position));
    }

    ArrayList<BazarItems> getBox() {
        ArrayList<BazarItems> box = new ArrayList<BazarItems>();
        for (BazarItems i : objects) {
            if (i.box)
                box.add(i);
        }
        return box;
    }

    OnCheckedChangeListener myCheckChangList = new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView,
                boolean isChecked) {
            getItems((Integer) buttonView.getTag()).box = isChecked;
        }
    };

`

  • 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-15T05:48:18+00:00Added an answer on June 15, 2026 at 5:48 am

    make filed in your CustomAdapter

    boolean isAllCHecked=false;
    

    and setter method for this like

     public setAllChecked()
     {
        isAllCHecked=true;
        notifyDataSetChanged();
     } 
    

    and in getView of your CustomAdapter do some thing like this

    //get instance of the checkbox
    //call checkBox.setChecked(isAllCHecked);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to check all the checkboxes on a webform (aspx) page, which
The thing I'm trying is to check all those checkboxes, when "cbkomplet" is checked.
i'm trying to check all checkboxes when inviting guests to a facebook event. Facebook
I am trying to parse through all elements in a single radio button (or
I am trying to implement the feature of checking and unchecking all checkboxes in
I am trying to check all checkboxes by onclick event on a checkbox labeled
i am trying to check/uncheck all checkboxes upon clicking on select all/deselect all checkbox
I am trying to get all checkboxes checked with: <script type=text/javascript> $(document).ready(function() { $(#delmsg_all).click(function()
I'm trying to create a check/uncheck all CheckBox for a number of CheckBoxes that
I am trying to check the following and all throw an out of bounds

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.