android - How can I conditionally hide last row of Listview inside ArrayAdapter? -


i have 2 fragments, contain lists (listview). in second fragment, each row (despite last one) contain checkbox. last row contain different layout (text + button) - that's because want displayed after list ends (not @ bottom of screen). want achieve is: when no checkbox checked last row visible, otherwise last row invisible. haven't find solution yet.. use getchild() refers visible items. have idea? thanks!

here getview method in arrayadapter:

public view getview(final int position, view convertview, final viewgroup parent) {

    viewholder holder = null;     final int last = this.getcount()-1;     int thetype = getitemviewtype(position);      if (convertview == null) {         if (thetype == 0) {             convertview = inflater.inflate(layoutresourceid, null);              holder = new viewholder();             holder.name = (textview) convertview                     .findviewbyid(r.id.name);             final checkbox checkbox = (checkbox) convertview.findviewbyid(r.id.checkeddealer);             checkbox.settag(position);             checkbox.setonclicklistener(new view.onclicklistener() {                  @override                 public void onclick(view v) {                     if(checkbox.ischecked()){                         checked++;                          if(checked==1){                             parent.getchildat(last).setvisibility(view.gone);                             notifydatasetchanged();                       }                     }                     else{                         checked--;                          if(checked==0){                             parent.getchildat(last).setvisibility(view.visible);                         }                     }                 }             });             convertview.settag(holder);         } else {             convertview = inflater.inflate(r.layout.list_search_dealer_footer, null);         }     } else {         holder = (viewholder) convertview.gettag();     }      if (thetype == 0) {         // object item based on position         dealer dealer = data.get(position);         holder.name.settext(dealer.getname());     }      return convertview; } 

you storing items information in array, right? 1 way want have 1 boolean field flag. each time checkbox checked or unchecked traverse array , check if there checked value, if has - set flag true else false. when have inflate last row, know if need inflate or return.


Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -