title: How to Stop a Loop at the Press of a Button
body: <p>I want the onClick method not only to create a new activity to the new page, but also to trigger the end of the loop, so that if someone clicks the background of the splash screen, the new screen doesn't reload after the loop stops.</p>
  
  <p>Here is my code,</p>
  
  <pre><code>package clouds.clouds;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  
  public class splash extends Activity {
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.splash);
       Thread logotimer = new Thread() {
  
  
              @Override
              public void run(){
                  try{
                      int logotimer = 0;
                      while(logotimer &lt;5000) {
                          sleep(100);
                          logotimer = logotimer +100;
  
                      }
                      startActivity(new Intent("clouds.clouds.SPLASH"));
                  } catch (InterruptedException e) {
                      // TODO Auto-generated catch block
                      e.printStackTrace();
                  }
                  finally{
                      finish();
                  }
  
              }
  
  
  
          };
        logotimer.start();
  
  
  }
  
  
  
      public void onClickz(View v){}
      public void speed2 (View v){
  
          startActivity(new Intent("clouds.clouds.BUTTONZ"));
      }
  
  
  
  }
  </code></pre>
  
  <p>Any suggestions?</p>