Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created July 3, 2012 02:57
Show Gist options
  • Save levinotik/3037245 to your computer and use it in GitHub Desktop.
Save levinotik/3037245 to your computer and use it in GitHub Desktop.
somewhere in my Android activity:
new Button().setOnClickListener(
new OnClickListener() {
public void onClick(View v) {
println(v.getId + "was clicked");
}
}
public interface OnClickListener(View v); //no method body defined
or
public class MyAndroidAppActivity extends Activity implements OnClickListener {
new Button().setOnClickListener(this) //where this is the click
@Override // just a helpful annotation for the reader
public void onClick(View v) {
println(v.getId + "was clicked");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment