Common class for click listener
问题 I have 7 buttons in all my 6 activities. All 6 buttons have the same functionality in all activities. How can I perform a common click event lisnter for these 6 buttons. 回答1: You can create a new class that implements View.OnClickListener like this: public class MyClickListener implements View.OnClickListener { @Override public void onClick(View view) { // TODO handle the click } } In all your activities you can then set the click listener like this: button.setOnClickListener(new