title: setVisibility(View.GONE) not removing space in listview item
body: <p>I am making a question that could be like a duplicated question, but i have tried everything and nothing worked for me. I have created a <strong>listview</strong> witch every item has two views, one <strong>textview</strong> and one <strong>checkbox</strong>. Its like a multiselect listview. Every item has a level on its own: easy, normal, hard. When a level is chosen from a dropdown: All, Easy, Normal, Hard.. the list changes, just like a filter system. 
  But when i write <code>listView.getChildAt(i).setVisibility(View.GONE);</code> the content of the row is removed but the space occupied is not released.</p>
  
  <p>Any help?</p>
  
  <p>This is my code:</p>
  
  <pre><code>public class CreatePresentation extends Activity
  {
      DatabaseHelper db = new DatabaseHelper(this);
      MyCustomAdapter dataAdapter = null;
      List&lt;Slider&gt; list;
      ListView listView;
      String Text;
  
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.create_presentation);
          displayListView();
          checkButtonClick();
      }
  
      private void displayListView()
      {
          list = new ArrayList&lt;Slider&gt;();
          ArrayList&lt;Slider&gt; oldList = db.getAllSliders();
  
          for (Slider anOldList : oldList) {
              String s = anOldList.toString();
              int in = anOldList.getId();
              String lev = anOldList.getLevel();
              Slider slider = new Slider(in, s, lev, false);
              list.add(slider);
          }
          dataAdapter = new MyCustomAdapter(this, R.layout.list_check_box, list);
          listView = (ListView) findViewById(R.id.listView);
          listView.setAdapter(dataAdapter);
      }
  
      private class MyCustomAdapter extends ArrayAdapter&lt;Slider&gt; {
          private ArrayList&lt;Slider&gt; list;
  
          public MyCustomAdapter(Context context, int textViewResourceId, List&lt;Slider&gt; list) {
              super(context, textViewResourceId, list);
              this.list = new ArrayList&lt;Slider&gt;();
              this.list.addAll(list);
          }
  
          private class ViewHolder {
              TextView text;
              CheckBox checkbox;
          }
  
          @Override
          public View getView(final int position, View convertView, ViewGroup parent) {
              final ViewHolder holder;
              final Slider slider = list.get(position);
  
              if (convertView == null) {
                  LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                  convertView = vi.inflate(R.layout.list_check_box, null);
  
                  holder = new ViewHolder();
  
                  holder.text = (TextView) convertView.findViewById(R.id.sliderTitle);
                  holder.checkbox = (CheckBox) convertView.findViewById(R.id.checkBox);
                  convertView.setTag(holder);
  
                  Spinner dropdown = (Spinner)findViewById(R.id.spinner);
                  String[] items = new String[]{"Tutto", "Facile", "Medio", "Difficile"};
                  ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String (CreatePresentation.this, android.R.layout.simple_spinner_item, items);
                  dropdown.setAdapter(adapter);
  
                  Text = dropdown.getSelectedItem().toString();
  
                  holder.checkbox.setOnClickListener(new View.OnClickListener() {
                      public void onClick(View v) {
                          CheckBox cb = (CheckBox) v;
                          Slider slider = (Slider) cb.getTag();
                          slider.setSelected(cb.isChecked());
                      }
                  });
  
                  try {
                      if (list.get(position).getLevel().equals("Facile"))
                          convertView.setBackgroundColor(Color.parseColor("#477C3D"));
                      else if (list.get(position).getLevel().equals("Medio"))
                          convertView.setBackgroundColor(Color.parseColor("#936019"));
                      else if (list.get(position).getLevel().equals("Difficile"))
                          convertView.setBackgroundColor(Color.parseColor("#A02307"));
                  } catch (Throwable e) {
                      e.printStackTrace();
                  }
  
                  dropdown.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
                      @Override
                      public void onItemSelected(AdapterView&lt;?&gt; parentView, View selectedItemView, final int position, long id) {
                          Text = parentView.getItemAtPosition(position).toString();
                          try {
                              if (Text.equals("All")){
                                  Runnable run = new Runnable(){
                                      public void run(){
                                          for (int i = 0; i &lt; list.size(); i++) {
                                              listView.getChildAt(i).setVisibility(View.VISIBLE);
                                          }
                                      }
                                  };
                                  runOnUiThread(run);
                              }
                              if (Text.equals("Easy")){
                                  Runnable run = new Runnable(){
                                      public void run(){
                                          for (int i = 0; i &lt; list.size(); i++) {
                                              if (list.get(i).getLevel().equals("Easy")) {
                                                  listView.getChildAt(i).setVisibility(View.VISIBLE);
                                              }
                                              else {
                                                  listView.getChildAt(i).setVisibility(View.GONE);
                                              }
                                          }
                                      }
                                  };
                                  runOnUiThread(run);
                              }
                              if (Text.equals("Normal")){
                                  Runnable run = new Runnable(){
                                      public void run(){
                                          for (int i = 0; i &lt; list.size(); i++) {
                                              if (list.get(i).getLevel().equals("Normal"))
                                                  listView.getChildAt(i).setVisibility(View.VISIBLE);
                                              else {
                                                  listView.getChildAt(i).setVisibility(View.GONE);
                                              }
                                              dataAdapter.notifyDataSetChanged();
                                          }
                                      }
                                  };
                                  runOnUiThread(run);
                              }
                              if (Text.equals("Hard")){
                                  Runnable run = new Runnable(){
                                      public void run(){
                                          for (int i = 0; i &lt; list.size(); i++) {
                                              if (list.get(i).getLevel().equals("Hard"))
                                                  listView.getChildAt(i).setVisibility(View.VISIBLE);
                                              else
                                                  listView.getChildAt(i).setVisibility(View.GONE);
                                          }
                                      }
                                  };
                                  runOnUiThread(run);
                              }
                          } catch (Throwable e) {
                              e.printStackTrace();
                          }
                      }
                      @Override
                      public void onNothingSelected(AdapterView&lt;?&gt; parentView) {
                      }
                  });
  
                  holder.checkbox.setOnClickListener(new View.OnClickListener() {
                      public void onClick(View v) {
                          CheckBox cb = (CheckBox) v;
                          Slider slider = (Slider) cb.getTag();
                          slider.setSelected(cb.isChecked());
                      }
                  });
              }
              else
              {
                  holder = (ViewHolder) convertView.getTag();
              }
  
              holder.text.setText(slider.getQuestion());
              holder.checkbox.setChecked(slider.isSelected());
              holder.checkbox.setTag(slider);
  
              return convertView;
          }
      }
  </code></pre>