title: Progress bar Visibility
body: <p>I have a very simple scenario: I have to make my progress bar <em>invisible</em> at the starting, but on the button click, have to make it <em>visible</em> so that the tasks which I am running in the background will be done and till then my progress bar will run.</p>
  
  <p>I am using a very simple way. I have put the progress bar in XML, then simply at the <code>onCreate</code> method of the activity, first making it invisible by <code>mProgress.setVisibility(4)</code> and then when I am clicking my button trying to make this <em>visible</em> again.</p>
  
  <p>But unfortunately its not working! Anyone please reply why its not doing this.</p>
  
  <pre><code>mProgress = (ProgressBar) findViewById(R.id.progressBar);
  mProgress.setVisibility(4);
  
  btnSubmit.setOnClickListener(new OnClickListener() {
    public void onClick(View v) {
      strpatientid = txtpatientid.getText().toString();
  
      if (strpatientid.length() == 0) {
        Toast.makeText(getApplicationContext(),
                       "Enter the Patient ID",
                       Toast.LENGTH_LONG).show();
        return;
      }
      else {
        mProgress.setEnabled(false);
        mProgress.setVisibility(View.VISIBLE);
        setProgressBarVisibility(true);
      }
    }
  </code></pre>