title: android how to hide linearlayout when no checkbox is checked in listview
body: <p>i have a layout with listview and under it there is linearlayout with two buttons horizantally, i want when no checkbox is checked the two buttons hide, i try to make it but my code make the two buttons hide and a black instead of them appears , and when a checkbos is checked the two buttons don't appear, why ?</p>
  
  <pre><code>class RestaurantAdapter extends BaseAdapter {
      private ArrayList&lt;Boolean&gt; status = new ArrayList&lt;Boolean&gt;();
      private static LayoutInflater inflater = null;
      private ArrayList&lt;HashMap&lt;String, String&gt;&gt; data;
      Activity activity;
      LinearLayout layout;
  public RestaurantAdapter(Activity activity,
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; data, LinearLayout layout) {
      this.layout = layout;
      this.activity = activity;
      this.data = data;
      inflater = (LayoutInflater) activity
              .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      for (int i = 0; i &lt; data.size(); i++) {
          status.add(false);
      }
  }
  public int getCount() {
      return data.size();
  }
  public Object getItem(int position) {
      return position;
  }
  public long getItemId(int position) {
      return position;
  }
  public View getView(final int position, View convertView, ViewGroup parent) {
      View vi = convertView;
      if (vi == null)
          vi = inflater.inflate(R.layout.restaurant_multi_select_list_item,
                  null);
      TextView name = (TextView) vi
              .findViewById(R.id.restaurant_multi_select_title);
      ImageView image = (ImageView) vi
              .findViewById(R.id.restaurant_multi_select_list_item_image);
      CheckBox cb = (CheckBox) vi
              .findViewById(R.id.restaurant_multi_select_checkBox);
      cb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
          public void onCheckedChanged(CompoundButton buttonView,
                  boolean isChecked) {
              if (isChecked) {
                  status.set(position, true);
              } else {
                  status.set(position, false);
              }
          }
      });
      cb.setChecked(status.get(position));
      boolean allFalse = true;
      int j = 0;
      while (j &lt; status.size() &amp;&amp; allFalse) {
          if (status.get(j))
              allFalse = false;
          j++;
      }
      if (allFalse)
          layout.setVisibility(LinearLayout.INVISIBLE);
      else
          layout.setVisibility(LinearLayout.VISIBLE);
  
      HashMap&lt;String, String&gt; restaurant = data.get(position);
      name.setText(restaurant.get("name"));
  
      image.setImageResource(Integer.parseInt(restaurant.get("image")));
      return vi;
  }
  </code></pre>
  
  <p>}
  check the <code>allFalse</code> variable</p>
  
  <p> in the main activity </p>
  
  <pre><code>layout = (LinearLayout) findViewById(R.id.llButtons);
  
          lvRestaurants = (ListView) findViewById(R.id.lvRestaurants);
  
          ArrayList&lt;HashMap&lt;String, String&gt;&gt; alist = new ArrayList&lt;HashMap&lt;String, String&gt;&gt;();
          for (int i = 0; i &lt; restaurants.length; i++) {
              HashMap&lt;String, String&gt; hm = new HashMap&lt;String, String&gt;();
              hm.put("image", R.drawable.mcdonalds + "");
              hm.put("name", restaurants[i]);
              alist.add(hm);
          }
          RestaurantAdapter ra = new RestaurantAdapter(this, alist, layout);
          lvRestaurants.setAdapter(ra);
  </code></pre>
  
  <p>this is the xml </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;ListView
          android:id="@+id/lvRestaurants"
          android:layout_weight="1"
          android:layout_width="fill_parent"
          android:layout_height="0dip" &gt;
      &lt;/ListView&gt;
  
      &lt;LinearLayout
          android:id="@+id/llButtons"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
  
          android:orientation="horizontal" &gt;
  
          &lt;Button
              android:id="@+id/bDone"
              android:layout_width="153dp"
              android:layout_height="match_parent"
              android:text="Done" /&gt;
  
          &lt;Button
              android:id="@+id/bCancel"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:text="Cancel" /&gt;
      &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>