// Declaring a button, treating it as an object and finding the button that should be listened to by ID
Button button = (Button)findViewById(R.id.button);
// Event handling method (click)
button.setOnClickListener(
// Adding the listener
new Button.OnClickListener(){
// Event executed method
public void onClick(View v) {
// Declaring a textView, treating it as an object and finding the textView that should change value when event is executed
TextView textView = (TextView)findViewById(R.id.textView);
// Changing the value of the textView
textView.setText("Clicked");
}
}
);