title: LinearLayout hide once when uncheck the first checkbox of customize ListView
body: <p>i saw this question <a href="https://stackoverflow.com/questions/14469590/android-how-to-hide-linearlayout-when-no-checkbox-is-checked-in-listview">android how to hide linearlayout when no checkbox is checked in listview</a>
  i have listview with checkbox in each row, i want when there is at least one checkbox is selected a linearylayout (contains two buttons) to be visible and when no checkbox is selected i want that lineylayout to hide, </p>
  
  <p>i made exactly like that question but it works just with the first checkbox, i mean when i check the firstcheckbox it work, then if i uncheck the linearlayout hide but if i check another checkbox the linearlayout still visible all the time
  adapter</p>
  
  <pre><code>public class AdapterFavoriteFoods extends BaseAdapter {
  
      private ArrayList&lt;Boolean&gt; cb_status = new ArrayList&lt;Boolean&gt;();
      private static LayoutInflater inflater = null;
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
      Activity activity;
      LinearLayout ll_CancelDone;
      private int checkedBoxs = 0;
      CheckBox[] allCheckBoxes;
  
      public AdapterFavoriteFoods(Activity activity,
              ArrayList&lt;HashMap&lt;String, String&gt;&gt; data, LinearLayout ll_CancelDone) {
          // TODO Auto-generated constructor stub
          this.activity = activity;
          this.data = data;
          this.ll_CancelDone = ll_CancelDone;
          inflater = (LayoutInflater) this.activity
                  .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          for (int i = 0; i &lt; data.size(); i++) {
              cb_status.add(false);
          }
          allCheckBoxes = new CheckBox[data.size()];
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return data.size();
      }
  
      @Override
      public Object getItem(int arg0) {
          // TODO Auto-generated method stub
          return arg0;
      }
  
      @Override
      public long getItemId(int position) {
          // TODO Auto-generated method stub
          return position;
      }
  
      @Override
      public View getView(final int position, View convertView, ViewGroup parent) {
          // TODO Auto-generated method stub
          View vi = convertView;
          if (vi == null)
              vi = inflater.inflate(R.layout.profile_list_item_checkbox, null);
          TextView tv_name = (TextView) vi
                  .findViewById(R.id.tv_profile_list_item_checkbox_title);
          ImageView iv_image = (ImageView) vi
                  .findViewById(R.id.iv_profile_list_item_checkbos_image);
          CheckBox cb_selected = (CheckBox) vi
                  .findViewById(R.id.cb_profile_list_item_checkbox_checkbox);
          allCheckBoxes[position] = cb_selected;
          cb_selected.setOnCheckedChangeListener(new OnCheckedChangeListener() {
  
              @Override
              public void onCheckedChanged(CompoundButton buttonView,
                      boolean isChecked) {
                  if (isChecked) {
                      cb_status.set(position, true);
                      checkedBoxs++;
                      if (ll_CancelDone.getVisibility() == View.GONE)
                          ll_CancelDone.setVisibility(View.VISIBLE);
                  } else {
                      cb_status.set(position, false);
                      checkedBoxs--;
                      if (checkedBoxs == 0)
                          ll_CancelDone.setVisibility(View.GONE);
                  }
              }
          });
          cb_selected.setChecked(cb_status.get(position));
  
          HashMap&lt;String, String&gt; hm = data.get(position);
          tv_name.setText(hm.get("name"));
          iv_image.setImageResource(Integer.parseInt(hm.get("image")));
          return vi;
      }
  }
  
  
    [1]: https://stackoverflow.com/questions/14469590/android-how-to-hide-linearlayout-when-no-checkbox-is-checked-in-listview
  </code></pre>
  
  <p>when i do this <code>Log.d("num", checkedBoxs+"");</code> in the else statemnt of oncheckchange the results still 1 , </p>