public class MainActivity extends Activity implements OnClickListener {
private Button bigButton, normalButton, smallButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
setListener();
}
private void setListener() {
bigButton.setOnClickListener(this);
normalButton.setOnClickListener(this);
smallButton.setOnClickListener(this);
}
private void initView() {
bigButton = (Button) findViewById(R.id.bigButton);
normalButton = (Button) findViewById(R.id.normalButton);
smallButton = (Button) findViewById(R.id.smallButton);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.bigButton:
bigButton.setBackgroundColor(Color.RED);
break;
case R.id.normalButton:
//
break;
case R.id.smallButton:
//
break;
default:
break;
}
}
}