Try moving these two lines in the onCreate().
Button button =(Button) findViewById(R.id.button1);
button.setOnClickListener(this);
Basically onClick is called only if the click listener is attached...and you cannot attach it inside the onClick because it won't be called until is attached :). Moving the 2 lines inside the onCreate ensure the listener is attached.