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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T00:03:45+00:00 2026-06-03T00:03:45+00:00

I want to select all check boxes in a listview but I’m not able

  • 0

I want to select all check boxes in a listview but I’m not able to get checkbox objects from the listview. I can select a single check box but not multiple check boxes.

Your suggestion are appreciable.

Code:

   public class MainActivity extends Activity {
   @Override
    public void onCreate(Bundle icicle) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.bir);
    mainListView = (ListView) findViewById(R.id.mainListView);
    selectall = (Button) findViewById(R.id.button1);
    selectall.setOnClickListener(this);
    save = (Button) findViewById(R.id.button2);
    save.setOnClickListener(this);

    mainListView.setOnItemClickListener(new AdapterView.OnItemClickListener()

            {
                @Override
                public void onItemClick(AdapterView<?> parent, View item,
                        int position, long id) {

                }
            });
  }
}

class Amphian:

 private static class Amphian 
        {
            private String name = "" ;
            private boolean checked = false ;
            public Amphian( String name ) 
            {
              this.name = name ;
            }
            public Amphian( String name, boolean checked )
            {
              this.name = name ;
              this.checked = checked ;
            }
            public String getName() {
              return name;
            }
            public void setName(String name) {
              this.name = name;
            }
            public boolean isChecked() {
              return checked;
            }
            public void setChecked(boolean checked) {
              this.checked = checked;
            }
            @Override
            public String toString() {
              return name ; 
            }
            public void toggleChecked() 
            {
              checked = !checked ;
            }
        }

class AmphiansArrayAdapter:

    public class AmphiansArrayAdapter extends ArrayAdapter<Amphian> 
         {
             Integer name[] =
                {
                     R.raw.ducks_landing_in_water, 
                     R.raw.flicker_chicks_feeding, 
                     R.raw.geese_honking_loud, 
                     R.raw.geese_honking_distant, 
                     R.raw.gold_finch, 
                     R.raw.humming_bird_feeding, 
                     R.raw.indigo_bunting, 
                     R.raw.loons,
                     R.raw.little_blue_heron_fishing,
                     R.raw.pelican_chick,
                     R.raw.purple_martins,
                     R.raw.red_winged_blackbird,
                     R.raw.shorebirds_close,
                     R.raw.shorebirds_distant,
                     R.raw.shorebirds_misc,
                     R.raw.shoreseabirds,
                     R.raw.snow_geese_flock,
                     R.raw.terns,
                     R.raw.tufted_titmouse,
                     R.raw.tundra_swans,
                     R.raw.wood_stork_chicks,
                     R.raw.woodpecker_tapping

                };

            private final LayoutInflater inflater;

            public AmphiansArrayAdapter(Context context, List<Amphian> amphianList) 
            {
                super( context, R.layout.simplerow, R.id.rowTextView, amphianList );
                 inflater = LayoutInflater.from(context) ;
            }

            @Override
            public View getView( final int position,  View convertView , ViewGroup parent)
            {
                final Amphian amphian=this.getItem(position);

                mp=new MediaPlayer();
                 if ( convertView == null ) 
                 {
                        convertView = inflater.inflate(R.layout.simplerow, null);

                        // Find the child views.

                        textView = (TextView) convertView.findViewById( R.id.rowTextView );
                        checkBox = (CheckBox) convertView.findViewById( R.id.checkBox1 );

                        button   = (Button)convertView.findViewById(R.id.button1);

                        // Optimization: Tag the row with it's child views, so we don't have to 
                        // call findViewById() later when we reuse the row.
                        convertView.setTag( new AmphianViewHolder(textView,checkBox,button) );

                        // If CheckBox is toggled, update the planet it is tagged with.
                        checkBox.setOnClickListener( new View.OnClickListener()
                        {
                          @Override
                        public void onClick(View v) 
                         {
                            cb= (CheckBox) v;
                            Log.e("cb",String.valueOf(cb));
                            Amphian amphian = (Amphian) cb.getTag();
                            Log.e("cb",String.valueOf(cb.getTag()));
                            amphian.setChecked(cb.isChecked());

                            Log.e("dd", "ddd");
                          }
                        });  

                        button.setOnClickListener(new OnClickListener()
                        {

                            @Override
                            public void onClick(View v)
                            {
                                Button bu=(Button)v;
                                Amphian amphian; 
                                //= (Amphian) bu.getTag();
                                //Log.e(String.valueOf(amphian),"ddd");
  • 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-03T00:03:47+00:00Added an answer on June 3, 2026 at 12:03 am

    There is too much code to read, so I give you a sample how to do that:

    int count = list.getCount();
    for (int i = 0; i < count; i++) {
        View child = list.getItemAtPosition(i);
        //check that child..
    }
    

    or

    int count = list.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = list.getChildAt(i);
        //check that child..
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to select all categories from a webservice. The webservice does not have
I want to select all internal links, which are in my document, but not
I want to disable/enable all checkboxes in listview. infact want to get select all
I want to create JSF table which has select all button and check box
I want to select all nodes <cci:p> that do not have an attribute. So,
Put simply, I want to select all data in two columns from each of
I have number of checkboxes and another checkbox for Select All I want to
How can I get the .val()'s and .html()'s of all the options from a
I want to select all the children of the body element before element with
I have a query where I want to select all users who like a

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.