title: Setting visibility of ListView
body: <p>I want to show my list view when the user clicks on a button and hide it again when they click on a button. This is the onClick listener for the button in question:</p>
  
  <pre><code>connectBtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              if(open){
                  mDbAdapter.close();
                  connectBtn.setText("Open Database");
                  open = false;
                  hideUI();
  
  
              }else{
                  mDbAdapter = new ContactsDbAdapter(v.getContext());
                  mDbAdapter.open();
                  connectBtn.setText("Close Database");
                  open = true;
                  showUI();
                  //retrieve data
                  fillData();
              }
          }
      });
  </code></pre>
  
  <p>This is the showUI() method:</p>
  
  <pre><code>protected void showUI() {
      fName.setVisibility(View.VISIBLE);
      lName.setVisibility(View.VISIBLE);
      fNameBox.setVisibility(View.VISIBLE);
      lNameBox.setVisibility(View.VISIBLE);
      createBtn.setVisibility(View.VISIBLE);
      this.setVisible(true);
  
      createBtn.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
              mDbAdapter.createContact(fNameBox.getText().toString(), lNameBox.getText().toString());
              fillData();
          }
      });
  }
  </code></pre>
  
  <p>and the hideUI() method:</p>
  
  <pre><code>protected void hideUI() {
      fName.setVisibility(View.INVISIBLE);
      lName.setVisibility(View.INVISIBLE);
      fNameBox.setVisibility(View.INVISIBLE);
      fNameBox.clearComposingText();
      lNameBox.setVisibility(View.INVISIBLE);
      lNameBox.clearComposingText();
      createBtn.setVisibility(View.INVISIBLE);
      this.setVisible(false);
  
  }
  </code></pre>
  
  <p>It works fine when I set the visibility to true. However when I set it to false I get a black screen but no crash or error. Any idea?</p>
  
  <p>NOTE: <code>this.setVisible(false);</code>. My class extends ListActivity.</p>