Guest User

Untitled

a guest
Nov 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. somewhere in my Android activity:
  2.  
  3. new Button().setOnClickListener(
  4. new OnClickListener() {
  5. public void onClick(View v) {
  6. println(v.getId + "was clicked");
  7. }
  8. }
  9.  
  10. public interface OnClickListener(View v); //no method body defined
  11.  
  12. or
  13.  
  14. public class MyAndroidAppActivity extends Activity implements OnClickListener {
  15. new Button().setOnClickListener(this) //where this is the click
  16.  
  17. @Override // just a helpful annotation for the reader
  18. public void onClick(View v) {
  19. println(v.getId + "was clicked");
  20.  
  21. }
  22. }
Add Comment
Please, Sign In to add comment