Skip to content

Instantly share code, notes, and snippets.

@gmsetiawan
Created July 6, 2014 15:13
Show Gist options
  • Save gmsetiawan/1aecae6f34e508183f00 to your computer and use it in GitHub Desktop.
Save gmsetiawan/1aecae6f34e508183f00 to your computer and use it in GitHub Desktop.
public class MyActivity extends Activity implements View.OnClickListener {
Button button1, button2, button3;
@Override
public void onCreate(Bundle bundle) {
super.onCreate();
/.../
button1 = (Button) findViewById(R.id.button1);
button2 = (Button) findViewById(R.id.button2);
button3 = (Button) findViewById(R.id.button3);
button1.setOnClickListener(this);
button2.setOnClickListener(this);
button3.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.button1:
// do stuff;
break;
case R.id.button2:
// do stuff;
break;
/.../
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment