After button click it changes variable | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

After button click it changes variable

I have a variable named ( _text-) I what to detect what button was clicked for example when button_a is clicked it then inserts the letter a at (3,  "a")  So now the variable _text- = "texat" ( coding in Android studio)

24th Apr 2018, 3:07 AM
Adrian Williamson
Adrian Williamson - avatar
1 Answer
0
You can have a char variable, say buttonChar and assign appropriate characters inside every button's onClick() function. You can finally use a switch case with buttonChar as your switch variable and manipulate variable _text.
25th Apr 2018, 1:10 PM
shylajhaa sathyaram
shylajhaa sathyaram - avatar