title: Change the visibility of textbox in android layout
body: <p>I have developed a layout which has 2 textboxes and 1 button. At the first, the button is appear and two textboxes are disappeared. However, I dont know how can I change the visibility of textboxes and other components to appear when the insert button is pressed. Please explain simply because I am new in android.</p>
  
  <pre><code>&lt;LinearLayout 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:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:orientation="vertical"
      android:paddingTop="@dimen/activity_vertical_margin"
      android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".Main3Activity"&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Name"
          android:id="@+id/textView"
          android:visibility="gone" /&gt;
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/editTextName"
          android:visibility="gone" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Address"
          android:id="@+id/textView2"
          android:visibility="gone" /&gt;
  
      &lt;EditText
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:id="@+id/editTextAddress"
          android:visibility="gone" /&gt;
  
      &lt;Button
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="Insert"
          android:onClick="insert"
          android:id="@+id/button" /&gt;
  
      &lt;TextView
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:id="@+id/textViewResult" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Main2Activity</p>
  
  <pre><code>package com.example.alan.mainactivity;
  import org.apache.http.util.EntityUtils;
  import android.content.Intent;
  import android.os.AsyncTask;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.widget.EditText;
  import android.widget.ListAdapter;
  import android.widget.ListView;
  import android.widget.SimpleAdapter;
  import android.widget.TextView;
  
  import org.apache.http.HttpEntity;
  import org.apache.http.HttpResponse;
  import org.apache.http.NameValuePair;
  import org.apache.http.client.ClientProtocolException;
  import org.apache.http.client.HttpClient;
  import org.apache.http.client.entity.UrlEncodedFormEntity;
  import org.apache.http.client.methods.HttpPost;
  import org.apache.http.impl.client.DefaultHttpClient;
  import org.apache.http.message.BasicNameValuePair;
  import org.apache.http.params.BasicHttpParams;
  import org.json.JSONArray;
  import org.json.JSONException;
  import org.json.JSONObject;
  import android.util.Log;
  import java.io.BufferedReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.List;
  import android.view.View;
  import android.widget.Toast;
  import android.view.View.OnClickListener;
  
  public class Main2Activity extends ActionBarActivity {
      public static final String USER_NAME1 = "USERNAME";
  
      String myJSON;
      private EditText editTextName;
      private EditText editTextAdd;
      private static final String TAG_RESULTS="result";
      private static final String TAG_ID = "id";
      private static final String TAG_NAME = "name";
      private static final String TAG_ADD ="address";
  
      JSONArray peoples = null;
  
      ArrayList&lt;HashMap&lt;String, String&gt;&gt; personList;
  
      ListView list;
  
  
  
      Button btn_insert=(Button)findViewById(R.id.button);
      btn_insert.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
  
              TextView textView= (TextView)findViewById(R.id.textView);
              textView.setVisibility(View.VISIBLE);
  
              //Similarly the other views.....
          }
      });
  
  
  
      public void insert(View view){
  
          String name = editTextName.getText().toString();
          String add = editTextAdd.getText().toString();
  
          insertToDatabase(name, add);
      }
  
      private void insertToDatabase(String name, String add){
          class SendPostReqAsyncTask extends AsyncTask&lt;String, Void, String&gt; {
              @Override
              protected String doInBackground(String... params) {
                  String paramUsername = params[0];
                  String paramAddress = params[1];
  
  
                  String name = editTextName.getText().toString();
                  String add = editTextAdd.getText().toString();
                  Intent intent = getIntent();
                  String username = intent.getStringExtra(MainActivity.USER_NAME).toString();
  
                  List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                  nameValuePairs.add(new BasicNameValuePair("name", name));
                  nameValuePairs.add(new BasicNameValuePair("address", add));
                  nameValuePairs.add(new BasicNameValuePair("user", username));
  
                  try {
                      HttpClient httpClient = new DefaultHttpClient();
                      HttpPost httpPost = new HttpPost(
                              "http://www.oobac.com/app/insert-db.php");
                      httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
                      HttpResponse response = httpClient.execute(httpPost);
  
                      HttpEntity entity = response.getEntity();
  
  
                  } catch (ClientProtocolException e) {
  
                  } catch (IOException e) {
  
                  }
                  return "success";
              }
  
              @Override
              protected void onPostExecute(String result) {
                  super.onPostExecute(result);
  
                  Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
                  TextView textViewResult = (TextView) findViewById(R.id.textViewResult);
                  textViewResult.setText("Inserted");
              }
          }
          SendPostReqAsyncTask sendPostReqAsyncTask = new SendPostReqAsyncTask();
          sendPostReqAsyncTask.execute(name, add);
      }
      //-----------------------
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_user_profile);
  
          Intent intent = getIntent();
          String username = intent.getStringExtra(MainActivity.USER_NAME);
          editTextName = (EditText) findViewById(R.id.editTextName);
          editTextAdd = (EditText) findViewById(R.id.editTextAddress);
         TextView textView = (TextView) findViewById(R.id.textView3);
  
         textView.setText("Welcome " + username);
  
          list = (ListView) findViewById(R.id.listView);
          personList = new ArrayList&lt;HashMap&lt;String,String&gt;&gt;();
          getData();
      }
  
  
  
      protected void showList(){
  
          try {
              JSONObject jsonObj = new JSONObject(myJSON);
              peoples = jsonObj.getJSONArray(TAG_RESULTS);
  
              for(int i=0;i&lt;peoples.length();i++){
                  JSONObject c = peoples.getJSONObject(i);
                  String id = c.getString(TAG_ID);
                  String name = c.getString(TAG_NAME);
                  String address = c.getString(TAG_ADD);
  
                  HashMap&lt;String,String&gt; persons = new HashMap&lt;String,String&gt;();
  
                  persons.put(TAG_ID,id);
                  persons.put(TAG_NAME,name);
                  persons.put(TAG_ADD,address);
  
                  personList.add(persons);
              }
  
              ListAdapter adapter = new SimpleAdapter(
                      Main2Activity.this, personList, R.layout.list_item,
                      new String[]{TAG_ID,TAG_NAME,TAG_ADD},
                      new int[]{R.id.id, R.id.name, R.id.address}
              );
  
              list.setAdapter(adapter);
  
          } catch (JSONException e) {
              e.printStackTrace();
          }
  
      }
  
      public void getData(){
          class GetDataJSON extends AsyncTask&lt;String, Void, String&gt;{
  
              @Override
              protected String doInBackground(String... params) {
                  //--------------------------------------------
                  Intent intent = getIntent();
                  String username = intent.getStringExtra(MainActivity.USER_NAME);
                  ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                  nameValuePairs.add(new BasicNameValuePair("username", username));
  
                  try {
                      HttpClient httpclient = new DefaultHttpClient();
                      HttpPost httppost = new HttpPost("http://www.oobac.com/app/amir.php");
                      httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs, "UTF-8"));
                      HttpResponse response = httpclient.execute(httppost);
                      String st = EntityUtils.toString(response.getEntity());
                      Log.d("TK SUPPORT", "In the try Loop" + st);
                      myJSON = st;
  
                  } catch (Exception e) {
                      Log.d("TK SUPPORT", "Connection Error : " + e.toString());
                  }
                  return "OK";
  
  
  
              }
  
              @Override
              protected void onPostExecute(String result) {
                  super.onPostExecute(result);
                  showList();
              }
  
  
  
          }
  
          GetDataJSON g = new GetDataJSON();
          g.execute();
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.menu_main, menu);
          return true;
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle action bar item clicks here. The action bar will
          // automatically handle clicks on the Home/Up button, so long
          // as you specify a parent activity in AndroidManifest.xml.
          int id = item.getItemId();
  
          //noinspection SimplifiableIfStatement
          if (id == R.id.action_settings) {
              return true;
          }
  
          return super.onOptionsItemSelected(item);
      }
  
  
  }
  </code></pre>