I have multiple buttons on the same activity each invoking the method “guessMade()” when they are clicked.
Every time a button is clicked, I would like to set the name of that button as the message that is going to be displayed in a TextView. Needless to say, TextView is also already created.
My code is as follows:
public void guessMade(View view){
CharSequence s = ((Button)view).getText();
TextView t = (TextView)view.findViewById(R.id.textView1);
t.setText(s);
}
Where do I fail ?
there is probably something wrong with your variable “s”.
try replacing
with
and see if it works.