Selection of all check boxes in listview
<p>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.</p>

<p>Your suggestion are appreciable. </p>

<p><em>Code:</em></p>

<pre><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&lt;?&gt; parent, View item,
                        int position, long id) {

                }
            });
  }
}
</code></pre>

<p><em>class Amphian:</em></p>

<pre><code> 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 ;
            }
        }
</code></pre>

<p><em>class AmphiansArrayAdapter:</em></p>

<pre><code>    public class AmphiansArrayAdapter extends ArrayAdapter&lt;Amphian&gt; 
         {
             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&lt;Amphian&gt; 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");
</code></pre>
