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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:27:08+00:00 2026-06-13T17:27:08+00:00

I want to unchecked my all check boxes inside listview on button click. This

  • 0

I want to unchecked my all check boxes inside listview on button click.
This my adapter class. It unchecked all check boxes but for that I have to scroll through listview.
When I scroll through it, it unchecked according to the rows that are visible.

public class ExpenseCalculatorAdapter extends ArrayAdapter<String>{
    private Activity context;
    private static LayoutInflater inflator = null;
    private  ArrayList<String> data;
    private  ArrayList<String> values;
    DataBaseUtil dbUtils;


    public ExpenseCalculatorAdapter(Activity context, ArrayList<String> data){
        super(context,R.layout.expenserow, data);
        this.context = context;
        this.data = data;
        dbUtils=new DataBaseUtil(context);


    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        String row=data.get(position);
        String date;
        String type;
        String cost;
        final String id;
        /*  result.add(c.getString(iRowid)+"&"+c.getString(iDate)+"~"+c.getString(iCost)+"#"+c.getString(iType)+"*");*/
        id=row.substring(0, row.indexOf("&"));
        date=row.substring(row.indexOf("&")+1,row.indexOf("~"));
        cost=row.substring(row.indexOf("~")+1,row.indexOf("#"));
        type=row.substring(row.indexOf("#")+1,row.indexOf("*"));

        if(convertView==null)
        {
            ViewHolder holder = new ViewHolder();
            inflator = context.getLayoutInflater();
            convertView = inflator.inflate(R.layout.expenserow, null);

            holder.togCheck=(CheckBox)convertView.findViewById(R.id.check);
            holder.textDate = (TextView) convertView.findViewById(R.id.txtrowDate);
            holder.textType = (TextView) convertView.findViewById(R.id.txtrowType);
            holder.textCost = (TextView) convertView.findViewById(R.id.txtrowCost);

            holder.togCheck.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    // TODO Auto-generated method stub
                    Intent intent=new Intent();
                    intent.setAction("clicked");
                    if(buttonView.isChecked())
                    {
                        try
                        {
                            dbUtils.open();
                            dbUtils.setVisibility(id);
                        }catch(SQLException sqx)
                        {
                            sqx.printStackTrace();
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }
                        finally
                        {
                            dbUtils.close();
                        }
                        intent.putExtra("isClicked","yes");
                        intent.putExtra("ID",""+id);
                        context.sendBroadcast(intent);
                    }
                    else
                    {
                        try
                        {
                            dbUtils.open();
                            dbUtils.setInVisibility(id);
                        }catch(SQLException sqx)
                        {
                            sqx.printStackTrace();
                        }
                        catch(Exception ex)
                        {
                            ex.printStackTrace();
                        }
                        finally
                        {
                            dbUtils.close();
                        }
                        intent.putExtra("isClicked","no");
                        intent.putExtra("ID",""+id);
                        context.sendBroadcast(intent);

                    }
                }
            });




            convertView.setTag(holder);

        }

        ViewHolder hold = (ViewHolder) convertView.getTag();

        //setting Data to List
        hold.textDate.setText(date);
        hold.textType.setText(type);
        hold.textCost.setText(cost);



        if(CheckReceiver.checkAll)
        {
            hold.togCheck.setChecked(true);


        }
        if(!CheckReceiver.checkAll)
        {
            hold.togCheck.setChecked(false);
        }


        return convertView;
    }



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



    static class ViewHolder{

        public CheckBox togCheck;
        public TextView textDate;
        public TextView textType;
        public TextView textCost;

    }

}
  • 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-13T17:27:09+00:00Added an answer on June 13, 2026 at 5:27 pm

    As Listview recycles view its not possible to do this with only BroadCastReciver. It was really a bad idea.
    I done this using Database and BroadCastReciver.

    holder.togCheck.setOnClickListener(new OnClickListener() {
    
                    @Override
                    public void onClick(View v) {
                        // TODO Auto-generated method stub
                        /*Intent intent=new Intent();
                        intent.setAction("clicked")*/;
                        if(holder.togCheck.isChecked())
                        {
                            //holder.togCheck.setBackgroundResource(R.drawable.check);
                            try
                            {
                                dbUtils.open();
                                dbUtils.setVisibility(id);
                            //  Toast.makeText(context, "Checked ", Toast.LENGTH_SHORT).show();
                            }catch(SQLException sqx)
                            {
                                sqx.printStackTrace();
                            }
                            catch(Exception ex)
                            {
                                ex.printStackTrace();
                            }
                            finally
                            {
                                dbUtils.close();
                            }
                            intent.putExtra("isClicked","yes");
                            intent.putExtra("ID",""+id);
                            context.sendBroadcast(intent);
                        }
                        else
                        {
                        //  holder.togCheck.setBackgroundResource(R.drawable.uncheck);
    
                            try
                            {
                                dbUtils.open();
                                dbUtils.setInVisibility(id);
                                Toast.makeText(context, "UnChecked ", Toast.LENGTH_SHORT).show();
                            }catch(SQLException sqx)
                            {
                                sqx.printStackTrace();
                            }
                            catch(Exception ex)
                            {
                                ex.printStackTrace();
                            }
                            finally
                            {
                                dbUtils.close();
                            }
                            intent.putExtra("isClicked","no");
                            intent.putExtra("ID",""+id);
                            context.sendBroadcast(intent);
                        }
                    }
                });
    

    what i done is i set the checked or unchecked state of checkbox according to id in database.
    Then by fetching state of that id i done calculation!.

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

Sidebar

Related Questions

I have one ListView, it contains check boxes. By default all check boxes are
http://developer.yahoo.com/yui/button More specifically, I want radio buttons. that can be checked/unchecked.
I have a listbox of checkboxes that I want to iterate through and check
I want to disable all unchecked checkboxes of a class when one of the
I want to have the first checkbox that allows me to check or uncheck
I would like to uncheck all checkboxes that have a specific class with the
I have a ListView in WPF Application with CheckBox inside. I am filling that
I have a bunch of checkboxes with a common attribute of class=all I want
I have this Jquery: $(document).ready(function() { $('#masterChecks input[type=checkbox]').click(function() { var togClass=$(this).attr('class'); if($(this).attr('checked')){ //need to
I want to check if a checkbox just got unchecked, when a user clicks

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.