title: Progress bar onclick button in android?
body: <p>How to bring a progress bar on clicking a button in an activity i have an button in my main activity and if i click the button i want to display a progress bar i dont wanna use a secondary activity for this i have done with 2 activities but i need it to be done in main activity itself.</p>
  
  <p>thank you</p>
  
  <p>My code:</p>
  
  <p>Home Activity :</p>
  
  <pre><code>public void load(View v){
      Intent intent = new Intent(this,Splash.class);
      this.startActivity(intent);
  }
  </code></pre>
  
  <p>Splash Activity :</p>
  
  <pre><code>public class Splash extends Activity {
      private long ms = 0;
      private long splashTime = 20000;
      private boolean splashActive = true;
      private boolean paused = false;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.splash);
  
          Thread mythread = new Thread() {
              public void run() {
                  try {
                      while (splashActive &amp;&amp; ms &lt; splashTime) {
                          if (!paused)
                              ms = ms + 100;
                          sleep(100);
                      }
                  } catch (Exception e) {
                  } finally {
                      Intent intent = new Intent(Splash.this, Home.class);
                      startActivity(intent);
                  }
              }
          };
          mythread.start();
      }
  }
  </code></pre>