title: how to show/hide layout on button click
body: <p>i want to have two relativelayout in first relativelayout have map and in second relativelayout i have the list..,i want on starting only layout with map will be visible on screen with a button,,when i click on button then layout with listview get open from right side with new new button on the top of it,,and prevoius button get hide.and screen get divided with two parts with different layouts..i have done some thing but from starting onward m getting half half screen.</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:id="@+id/ListView_layout"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:weightSum="1" &gt;
  
      &lt;RelativeLayout
          android:id="@+id/rl_ListView1"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="0.5" &gt;
  
          &lt;Button
              android:id="@+id/getdirection"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
  
              android:text="Get Directions" /&gt;
  
          &lt;fragment
              android:id="@+id/map"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              class="com.google.android.gms.maps.MapFragment" &gt;
          &lt;/fragment&gt;
      &lt;/RelativeLayout&gt;
  
      &lt;RelativeLayout
          android:id="@+id/rl_ListView2"
          android:layout_width="0dp"
          android:layout_height="match_parent"
          android:layout_weight="0.5"
          android:visibility="invisible" &gt;
  
          &lt;Button
              android:id="@+id/hide"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
  
              android:text="Get Directions" /&gt;
  
          &lt;ListView
              android:id="@+id/list"
              android:layout_width="fill_parent"
              android:layout_height="wrap_content"
              android:background="@android:color/white"
              android:visibility="invisible" /&gt;
      &lt;/RelativeLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>MainActivity</strong></p>
  
  <pre><code> show = (TextView)findViewById(R.id.getdirection);
           show1 = (TextView)findViewById(R.id.hide);
           rt = (RelativeLayout)findViewById(R.id.rl_ListView2);
  show.setOnClickListener(new OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
                              // TODO Auto-generated method stub
  
                              if(rt.getVisibility()==View.INVISIBLE)
                              {
                                  rt.setVisibility(View.VISIBLE);
  
                              }
                             show.setVisibility(View.INVISIBLE);
  
  
                          }
                      });
  show1.setOnClickListener(new OnClickListener() {
  
                          @Override
                          public void onClick(View v) {
                              // TODO Auto-generated method stub
  
                              if(rt.getVisibility()==View.VISIBLE)
                              {
                                  rt.setVisibility(View.INVISIBLE);
  
                              }
                             show1.setVisibility(View.INVISIBLE);
  
  
                          }
                      });
  </code></pre>