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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:26:13+00:00 2026-06-15T12:26:13+00:00

i am having custom arrayadapter for listview, which has 5 views inside including checkbox,

  • 0

i am having custom arrayadapter for listview, which has 5 views inside including checkbox, here i want to implement the select all checkboxes of listview and deselect all checkboxes, i tried with getchildat() method in the oncreate(), onresume(), and onpostcreate also but does not made luck to me. i appreciate if you can tell me the solution.

@Override
      public void onPostCreate(Bundle savedInstanceState){
          super.onPostCreate(savedInstanceState);

      Button selectall=(Button) findViewById(R.id.allselect);

      selectall.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            int count = listview.getCount();

            System.out.println("the count is "+count);
            for (int i = 0; i < listview.getLastVisiblePosition() - listview.getFirstVisiblePosition(); i++)  {

                RelativeLayout itemLayout = (RelativeLayout)listview.getChildAt(i);
                CheckBox cb = (CheckBox)itemLayout.findViewById(R.id.chkbx);
                cb.setChecked(true);

            }

        }
    });
  }

Arrayadapter class

@SuppressWarnings("unchecked")
    public MultipleLeadSyncAdapter(Context context, String[] values,String[] values1,List<Model> qrcode ,String[] values3,String[] values4,String[] values5) {
        super(context, R.layout.multipleselectlist, values1);
        this.context = context;
        this.values = values;
        this.values1 = values1;
        this.list=qrcode;
        this.values3=values3;
        this.values4=values4;
        this.eventid=values5;
    }

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = (LayoutInflater) context
            .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 


    ViewHolder holder =null;
    if (convertView == null) {


            convertView = inflater.inflate(R.layout.multipleselectlist, parent, false);

            holder = new ViewHolder();
            holder.textView1 = (TextView) convertView.findViewById(R.id.multileadfirst_name);

            holder.textView3 = (TextView) convertView
                    .findViewById(R.id.multileadcompany_name);

            holder.rate=(RatingBar) convertView.findViewById(R.id.multileadlistrating);

            holder.chkbox = (CheckBox) convertView.findViewById(R.id.chkbx);

            holder.chkbox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {

                @Override
                public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    int getPosition = (Integer) buttonView.getTag();  
                    list.get(getPosition).setSelected(buttonView.isChecked()); 
                }
            });

            convertView.setTag(holder);
            convertView.setTag(R.id.chkbx,holder.chkbox);
            convertView.setTag(R.id.multileadfirst_name,holder.textView1);
            convertView.setTag(R.id.multileadcompany_name,holder.textView3);
            convertView.setTag(R.id.multileadlistrating,holder.rate);

    }else {
        holder = (ViewHolder) convertView.getTag();
    }


     holder = (ViewHolder) convertView.getTag();


    holder.textView1.setText(values[position]);

    if(values3[position].equals(" ")||values3[position].equals("null")||values3[position].equals("")){

    }else{

        String[] temp=values3[position].split(" ");

    }

    holder.textView3.setText(values1[position]);

    holder.rate.setRating(Float.valueOf(values4[position]).floatValue());

    String s = values[position];
    String ss = values1[position];

    System.out.println(s + ss );


    holder.chkbox.setTag(position);

    //holder.textView3.setText(list.get(position).getName());
    holder.chkbox.setChecked(list.get(position).isSelected());
    String igurl=values[position];
    System.out.println("the imagurl is "+igurl);

    return convertView;



}

class ViewHolder {

    String qrcode,Boothid;
    TextView textView1, textView2, textView3,textView4,textView5;
    RatingBar rate;
    ImageView imageView;
    CheckBox chkbox;

    public String getQrcode() {
        return qrcode;
    }

    public void setQrcode(String qrcode) {
        this.qrcode = qrcode;
    }

    public String getBoothID() {
        return Boothid;
    }

    public void setBoothID(String Boothid) {
        this.Boothid = Boothid;
    }

}

}

  • 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-15T12:26:15+00:00Added an answer on June 15, 2026 at 12:26 pm

    A ListView is just a presentation of data. The data is given to the ListView by an Adapter. This being said, I can explain what you did wrong:

    Inside your OnClickListener, you are (un)checking a View of the ListView itself. This means the data is not being changed and the ListView which represents this data, does not display the wanted behavior.

    A simple solution would be adding a boolean to your Model-object which indicates the checked-state:

    Model {
       boolean isChecked = false;
    
       public void setChecked(boolean checked){
            isChecked = checked;
       }
    
       public boolean isChecked(){
            return isChecked;
       }
    }
    

    Whenever you click the ‘selectall’-button, you will simple toggle this boolean and notify the Adapter that his data has changed with the method notifyDataSetChanged. This will on his turn update the ListView itself. In pseudocode:

     onClick(..) {
         foreach (model inside my adapter){
             model.setChecked(true);
         }
         listview.getAdapter().notifyDataSetChanged()
     }
    

    Last but not least, in the getView()-method inside your Adapter you can see if a Model is checked or not and act accordingly.

    getView(...){
    
       if (listOfModel.get(position).isChecked){
           // do stuff, probably check a CheckBox
       } else {
           // uncheck...
       }
    

    Good luck!

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

Sidebar

Related Questions

I'm having a problem with my ListView in a ListActivity with a Custom ArrayAdapter.
I have a listview with custom row having a textview and a clickable image
I'm having a strange issue with a custom implementation of Android's ArrayAdapter. To give
I am having custom listview(with image, text and check box) and a button(named Done)
I am having custom Listview. Every row in listview contains image and textview. After
I am having a custom 'tableview' implementation. I am implementing a feature which I
Interesting problem I'm having with a ListView. It's using a standard ArrayAdapter, with a
I'm having a custom control that 'can' have a ListCollectionView passed as ItemsSource, which
i am having an custom alert view which pop ups on a button click
Having searched for a way to enforce immutability of custom types and not having

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.