title: Android onClickListener works only once, Button does not works for second time
body: <p>I am new in android Programming , Here is the code in which checkButton works only for once . Nothing happens when I click it for the second time. I can't seem to find problem. </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>import android.app.AlertDialog;
  import android.app.ProgressDialog;
  import android.content.Context;
  import android.net.ConnectivityManager;
  import android.net.NetworkInfo;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class MainActivity extends AppCompatActivity {
      ProgressDialog progress;
      Button checkButton;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          checkButton = (Button) findViewById(R.id.button);
          checkButton.setOnClickListener(
              new View.OnClickListener(){
                  @Override
                  public void onClick(View v){
  
                      EditText aNumber = (EditText) findViewById(R.id.editText);
                      String aCount = aNumber.getText().toString();
                      boolean totalDigit = aCount.length()==16;
                      if(totalDigit){
                       if(checkConnectivity()) {
                         progress = new ProgressDialog(v.getContext());
                         progress.setTitle("Validating Number");
                         progress.setMessage("Processing...");
                         progress.setCancelable(true);
                         progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                         progress.show();
                         new Thread(new Runnable() {
                             public void run() {
                                 try {
                                     Thread.sleep(5000);
                                 } catch (Exception e) {
                                     e.printStackTrace();
                                 }
                                 progress.dismiss();
                                 MainActivity.this.runOnUiThread(new Runnable()
                                 {
                                     public void run()
                                     {
                                         //Do your UI operations like dialog opening or Toast here
                                         showAlert();
                                     }
                             });
                         }
                         }).start();
  
                     }else{
                         Toast.makeText(MainActivity.this,"Internet Connection is not Available",Toast.LENGTH_SHORT).show();
                     }}else {
                           Toast.makeText(MainActivity.this, "Please enter correct 16 digit number",Toast.LENGTH_SHORT).show();
                          }
  
                  }
              });
           }
  //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
           private void showAlert(){
               AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
               
               builder.setMessage("Number not found!");
               builder.setCancelable(true);
              
  
               //Creating dialog box
               AlertDialog alert = builder.create();
               //Setting the title manually
               alert.setTitle("Number Status");
               alert.show();
               setContentView(R.layout.activity_main);
  
           }
  
  /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         private boolean checkConnectivity(){
             ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);
             if(connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState() == NetworkInfo.State.CONNECTED ||
                     connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI).getState() == NetworkInfo.State.CONNECTED) {
                 return  true;
             }
             else {
                 return false;
             }
         }
  
  
      }</code></pre>
  </div>
  </div>
  </p>
  
  <p>My Check Button works for only once. After I press it for second time nothings happen. I have looked all previous answer related to this in stackoverflow but nothings helped me. Please someone tell me what is going wrong.</p>