What if we have to find a single view down in the list On Jun 3, 7:20 pm, Streets Of Boston <flyingdutc...@gmail.com> wrote: > 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; > > }- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
[android-developers] Re: Problem with getChildCount method???
narendrasingh.bi...@gmail.com Thu, 04 Jun 2009 03:32:04 -0700
- [android-developers] Problem with getChildCo... dark_messiah
- [android-developers] Re: Problem with g... Marco Nelissen
- [android-developers] Re: Problem wi... dark_messiah
- [android-developers] Re: Proble... Romain Guy
- [android-developers] Re: Pr... dark_messiah
- [android-developers] R... Streets Of Boston
- [android-developers] R... Aaron D'Souza
- [android-developer... Akash Gupta
- [android-developers] Re: Problem with g... Streets Of Boston
- [android-developers] Re: Problem wi... narendrasingh.bi...@gmail.com
- [android-developers] Re: Proble... Streets Of Boston
- [android-developers] Problem with getCh... dark_messiah