title: How to Register Multiple Listeners in Android?
body: <p>In iOS I can register multiple target+action event handlers for e.g. a button like this: </p>
  
  <pre><code>@implementation ViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(20, 40, 300, 40)];
      [button setBackgroundColor:[UIColor blueColor]];
      [button setTitle:@"Click Me!" forState:UIControlStateNormal];
      [button addTarget:self action:@selector(handler1) forControlEvents:UIControlEventTouchUpInside];
      [button addTarget:self action:@selector(handler2) forControlEvents:UIControlEventTouchUpInside];
      [self.view addSubview:button];
  }
  
  - (void)handler1 {
      NSLog(@"Click handler 1"); // FIRES!
  }
  
  - (void)handler2 {
      NSLog(@"Click handler 2"); // FIRES!
  }
  
  @end
  </code></pre>
  
  <p>I want to achieve something similar in Java/Android, unfortunately this won't work so far as the first listener gets replaced by the second:</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      Button button = (Button) findViewById(R.id.button);
      button.setText("Click Me!");
      button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          Log.d("Test", "Click handler 1"); // DOES NOT FIRE!
        }
      });
      button.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
          Log.d("Test", "Click handler 2"); // FIRES!
        }
      });
  
    }
  }
  </code></pre>
  
  <p>I appreciate any help &amp; suggestions to achieve the same in Java/Android!</p>