You have to do this through your BaseAdapter.
Make sure that your BaseAdapter's individual elements/items have a
variable that can determine if one is checked or not.

If you want to check-mark all your list-item item's, run through every
element in your BaseAdapter. Set every element to 'isChecked' (or call
whatever variable/method is available on your element's class to make
it checked).

Then call the BaseAdapter's 'notifyDataSetChanged()'.
This will cause your BaseAdapter's method 'getView(....)' to be called
for all (visible) list-items:
   Using the 'position' (paramater of 'getView'), get the
BaseAdapter's element on that position.
   Then query that element: if it is checked, check the list-view-
item's checkbox.
                            If not, clear this checkbox.

On Jun 2, 12:27 am, dark_messiah <ricky.dreamwea...@gmail.com> wrote:
> I have problem...i m using a base adapter for binding a data from
> array to listview....the listview has a checkbox with it...i wanted to
> create a menu to select all or deselect all view inside that
> list...but the getchildCount method is behaving abnormally..i m not
> able to get the correct child count...can anybody help me plz......???
>
> ..................................................
> ..................................................
> public boolean onOptionsItemSelected(final MenuItem item) {
>             if (item == mSelectAllItem ) {
>
>             LayoutInflater      mInflater = LayoutInflater.from(this);
>             View view = (View)mInflater.inflate(R.layout.list_item,
> null);
>
>                 ListView listView = getListView();
>
>             int listItemCount = listView.getChildCount();
>             int listItemCount1 = listView.getCount();
>             System.out.println("<<<<<<<<<Child Count in select
> all>>>>>>>>>>"+listItemCount);
>             System.out.println("<<<<<<<<< Count in select
> all>>>>>>>>>>"+listItemCount1);
>             for( int j=0;j<listItemCount;j++ )
> {
>                 CheckBox cbox=(CheckBox)((View)listView.getChildAt
> (j)).findViewById(R.id.alarmButton);
>                 if( !cbox.isChecked() ) {
>                      cbox.setChecked(true);
>                      System.out.println("TRUE");
>                  } else {
>                          System.out.println("FALSE");
>                  }
>             }
>
>         return true;
>       }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to