title: Android/Java Repeat Button Click
body: <p>I am writing my first android application, and am trying to write an app where you simply click a button to display a message, and can do so as many times as you want. So far I have:</p>
  
  <pre><code>public class MyProject extends Activity
  {
      @Override
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          final TextView tv = new TextView(this);
          Button startButton = (Button) findViewById(R.id.startbutton);
          startButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
              tv.setText("Hello World!");
              setContentView(tv);
              Handler handler = new Handler(); 
              handler.postDelayed(new Runnable() { 
              public void run() {setContentView(R.layout.main);}}, 2000);     
          }
          });
      }
  }
  </code></pre>
  
  <p>However doing it this way, when I get back to my main screen and click on the button again...nothing happens. How can I get repeated button clicks to repeat the behaviour? </p>