title: how to expand and collapse the textView which is having EditText as its child
body: <p>i am new to android..In my xml file i have used three textviews,
  inside that i have used three edittext for every textview..
  what i want is when i press a particular textview it has to expand to get their 
  child(edittexts)..and when i again press the textview should collapse back.</p>
  
  <p>Now in my code when i press textview it expands,but when i press again its not collapsing.</p>
  
  <p>Below is my code..any help would be appreciated...thanks in advance..</p>
  
  <h1>Java file</h1>
  
  <p>CategoryPage.java</p>
  
  <pre><code>import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class CategoryPage extends Activity {
  /** Called when the activity is first created. */
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_category_page);
  
      TextView btnProfile = (TextView) findViewById(R.id.btnprofile);
      TextView btnSettings = (TextView) findViewById(R.id.btncitizen);
      TextView btnPrivacy = (TextView) findViewById(R.id.btnprivacy);
  
      View panelProfile = findViewById(R.id.panelProfile);
      panelProfile.setVisibility(View.GONE);
  
      View panelSettings = findViewById(R.id.panelSettings);
      panelSettings.setVisibility(View.GONE);
  
      View panelPrivacy = findViewById(R.id.panelPrivacy);
      panelPrivacy.setVisibility(View.GONE);
  
      btnProfile.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              // DO STUFF
              View panelProfile = findViewById(R.id.panelProfile);
              panelProfile.setVisibility(View.VISIBLE);
  
              View panelSettings = findViewById(R.id.panelSettings);
              panelSettings.setVisibility(View.GONE);
  
              View panelPrivacy = findViewById(R.id.panelPrivacy);
              panelPrivacy.setVisibility(View.GONE);
  
          }
      });
  
      btnSettings.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              // DO STUFF
              View panelProfile = findViewById(R.id.panelProfile);
              panelProfile.setVisibility(View.GONE);
  
              View panelSettings = findViewById(R.id.panelSettings);
              panelSettings.setVisibility(View.VISIBLE);
  
              View panelPrivacy = findViewById(R.id.panelPrivacy);
              panelPrivacy.setVisibility(View.GONE);
  
          }
      });
  
      btnPrivacy.setOnClickListener(new OnClickListener() {
          @Override
          public void onClick(View v) {
              // DO STUFF
              View panelProfile = findViewById(R.id.panelProfile);
              panelProfile.setVisibility(View.GONE);
  
              View panelSettings = findViewById(R.id.panelSettings);
              panelSettings.setVisibility(View.GONE);
  
              View panelPrivacy = findViewById(R.id.panelPrivacy);
              panelPrivacy.setVisibility(View.VISIBLE);
  
              }
          });
      }
  }
  </code></pre>
  
  <h1>XML File</h1>
  
  <p>activity_category_page.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#fff"&gt;
  
  &lt;LinearLayout android:id="@+id/header"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="#fff"
          android:paddingLeft="0dp"
          android:paddingRight="0dp"
          android:paddingTop="5dip"
          android:paddingBottom="5dip"&gt;
  
  &lt;ImageView
      android:id="@+id/imageView1"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:layout_marginTop="0dp"
      android:src="@drawable/miiskylogo" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;ScrollView 
      android:layout_width="fill_parent"
      android:layout_height="fill_parent" 
      android:layout_below="@+id/header" &gt;
  
  &lt;LinearLayout 
       android:id="@+id/root_layout" 
       android:layout_width="fill_parent"
       android:layout_height="fill_parent" 
       android:background="#FFFFFFFF"
       android:layout_weight="1" 
       android:layout_marginTop="10dp"
       android:layout_marginLeft="7dp"
       android:layout_marginRight="7dp"
       android:orientation="vertical"&gt;
  
  &lt;TextView
              android:id="@+id/textview1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginBottom="15dp"
              android:text="@string/Text"
              android:textSize="20dp"
              android:textStyle="bold"/&gt;
  
   &lt;TextView 
       android:id="@+id/textview2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_below="@+id/textview1"
              android:text="@string/Text2"
              android:layout_marginBottom="10dp"
              android:textSize="13dp"
              /&gt;
  
  &lt;TextView
      android:id="@+id/btnprofile"
      android:layout_width="match_parent"
      android:layout_height="35dp"
      android:paddingLeft="10dp"
      android:paddingTop="10dp"
      android:background="@drawable/verifyedit"
      android:text="Profile Vault"
      android:textColor="#000"
      android:textSize="15dp" /&gt;
  
  &lt;LinearLayout 
      android:id="@+id/panelProfile"
      android:orientation="vertical" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:layout_weight="1"
      android:background="#FFFFFFFF"&gt;
  
          &lt;LinearLayout
              android:id="@+id/panelProfile1"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="17dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
              &lt;EditText
                  android:id="@+id/salutation"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="0.81"
                  android:background="@drawable/verifyedit"
                  android:ems="10"
                  android:paddingLeft="10dp"
                  android:hint="Salutation" &gt;
  
                  &lt;requestFocus /&gt;
              &lt;/EditText&gt;
          &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
              android:id="@+id/panelProfile2"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="8dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/firstname" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="First Name"  /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/panelProfile3"
          android:layout_width="280dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:layout_marginTop="8dp"
          android:layout_gravity="center_horizontal"
          android:background="#FFFFFFFF"
          android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/middlename" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Middle Name"  /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/panelProfile4"
          android:layout_width="280dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:layout_marginTop="8dp"
          android:layout_gravity="center_horizontal"
          android:background="#FFFFFFFF"
          android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/lastname" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Last Name"  /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  &lt;TextView
      android:id="@+id/btncitizen"
      android:layout_width="match_parent"
      android:layout_height="35dp"
      android:paddingLeft="10dp"
      android:paddingTop="10dp"
      android:layout_marginTop="15dp"
      android:background="@drawable/verifyedit"
      android:text="Citizenship/Registration"
      android:textColor="#000"
      android:textSize="15dp" /&gt;
  
  &lt;LinearLayout 
      android:id="@+id/panelSettings"
      android:orientation="vertical" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:layout_weight="1"
      android:background="#FFFFFFFF"&gt;
  
          &lt;LinearLayout
              android:id="@+id/panelSettings1"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="17dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
              &lt;EditText
                  android:id="@+id/currentaddress"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="0.81"
                  android:background="@drawable/verifyedit"
                  android:ems="10"
                  android:paddingLeft="10dp"
                  android:hint="Current address" &gt;
  
                  &lt;requestFocus /&gt;
              &lt;/EditText&gt;
          &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
              android:id="@+id/panelSettings2"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="8dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/houseno" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="House no"  /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/panelSettings3"
          android:layout_width="280dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:layout_marginTop="8dp"
          android:layout_gravity="center_horizontal"
          android:background="#FFFFFFFF"
          android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/roadno" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Road no"  /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/panelSettings4"
          android:layout_width="280dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:layout_marginTop="8dp"
          android:layout_gravity="center_horizontal"
          android:background="#FFFFFFFF"
          android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/location" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Location"  /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  &lt;TextView
      android:id="@+id/btnprivacy"
      android:layout_width="match_parent"
      android:layout_height="35dp"
      android:paddingLeft="10dp"
      android:paddingTop="10dp"
      android:layout_marginTop="15dp"
      android:background="@drawable/verifyedit"
      android:text="Banking"
      android:textColor="#000"
      android:textSize="15dp" /&gt;
  
  &lt;LinearLayout 
      android:id="@+id/panelPrivacy"
      android:orientation="vertical" 
      android:layout_width="fill_parent"
      android:layout_height="wrap_content" 
      android:layout_weight="1"
      android:background="#FFFFFFFF"&gt;
  
          &lt;LinearLayout
              android:id="@+id/panelPrivacy1"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="17dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
              &lt;EditText
                  android:id="@+id/bankacc"
                  android:layout_width="wrap_content"
                  android:layout_height="match_parent"
                  android:layout_weight="0.81"
                  android:background="@drawable/verifyedit"
                  android:ems="10"
                  android:paddingLeft="10dp"
                  android:hint="Bank account no" &gt;
                  &lt;requestFocus /&gt;
              &lt;/EditText&gt;
          &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
              android:id="@+id/panelPrivacy2"
              android:layout_width="280dp"
              android:layout_height="40dp"
              android:layout_weight="1"
              android:layout_marginTop="8dp"
              android:layout_gravity="center_horizontal"
              android:background="#FFFFFFFF"
              android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/acctype" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Account Type"  /&gt;
  
      &lt;/LinearLayout&gt;
  
      &lt;LinearLayout
          android:id="@+id/panelPrivacy3"
          android:layout_width="280dp"
          android:layout_height="40dp"
          android:layout_weight="1"
          android:layout_marginTop="8dp"
          android:layout_gravity="center_horizontal"
          android:background="#FFFFFFFF"
          android:orientation="horizontal" &gt;
  
          &lt;EditText 
              android:id="@+id/bankcredit" 
              android:layout_width="wrap_content"
              android:layout_height="match_parent"
              android:layout_weight="0.81"
              android:background="@drawable/verifyedit"
              android:ems="10"
              android:paddingLeft="10dp"
              android:hint="Bank Credit Card No"  /&gt;
  
      &lt;/LinearLayout&gt;
  &lt;/LinearLayout&gt;
  &lt;/ScrollView&gt;
  &lt;/RelativeLayout&gt;
  </code></pre>