Java では、この方法でボタンを作成した後:
Button button1= new Button();
この方法でボタンの参照を識別できます
public void actionPerformed(ActionEvent bottonName){
Button name_of_the_button= (Button)bottonName.getSource();
//Inside 'name_of_the_button' I have 'button1'
}
Androidで同じことを行うにはどうすればよいですか?私はこのようにしてみました
public void onClick(View bottonName) {
Button name_of_the_button= (Button )bottonName.getSource();
}
しかし、Android にはメソッド getSource() がありません。