In Java, if I want to set the value of a JLabel
when I click a JButton
, I can code it like this...
JButton button = new JButton("add");
JButton label = new JLabel();
public void addListenersToButtons(){
button.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
Object src = e.getSource();
if (src == button) {
label.setText("this is the number = " + number);
}
}
I want to be able to do a similar thing in Android, where I set the value of a TextField
when the user clicks a button. What is the appropriate code for this in Android?