title: Hiding linear layout on runtime in Android
body: <p>I am having following layout</p>
  
  <pre><code>&lt;merge&gt;
      &lt;LinearLayout
          android:id="@+id/ll_main"
          android:layout_height="fill_parent"
          android:layout_width="fill_parent"
          /&gt;
      &lt;LinearLayout
          android:id="@+id/ll_sub"
          android:layout_height="fill_parent"
          android:layout_width="fill_parent"
          /&gt;  
  &lt;/merge&gt;
  </code></pre>
  
  <p>What I want to do is to show/hide the ll_sub layout on runtime through <code>setVisibility()</code> but it is not working.</p>
  
  <p>When I am setting <code>android:visibility="gone"</code> (also I had checked with <code>invisible</code>) from the xml of <code>ll_sub</code> then it is not displayed on the screen and this time when I use <code>setVisibility()</code> to show this layout on runtime, it is displayed but when I try to hide this layout once it is displayed then it is not hiding.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am trying to show/hide this linear layout on click of a button.</p>
  
  <pre><code>LinearLayout ll;
  Button minimize;
  int visibility=0;
  
  @Override
  public void onCreate(Bundle savedInstanceState)
  {
      ll=(LinearLayout)findViewById(R.id.ll_sub);
      minimize=(Button)findViewById(R.id.minimize);
      minimize.setOnClickListener(new View.OnClickListener()
      {
          public void onClick(View view)
          {
  
              if(visibility==0)
              {
                  visibility=2;
              }
              else
              {
                  visibility=0;
              }
              ll.setVisibility(visibility);
  
          }
      });
  }
  </code></pre>