Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. // Declaring a button, treating it as an object and finding the button that should be listened to by ID
  2. Button button = (Button)findViewById(R.id.button);
  3.  
  4. // Event handling method (click)
  5. button.setOnClickListener(
  6. // Adding the listener
  7. new Button.OnClickListener(){
  8. // Event executed method
  9. public void onClick(View v) {
  10. // Declaring a textView, treating it as an object and finding the textView that should change value when event is executed
  11. TextView textView = (TextView)findViewById(R.id.textView);
  12. // Changing the value of the textView
  13. textView.setText("Clicked");
  14. }
  15. }
  16. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement