I have a few variables(edit Text and text View) and some buttons,and I want each one of the buttons do something different with the same variables. is there anyway that I won’t need to define all the variables for each onClickListener? I’ve seen this post but I think my question is opposite of that!
As an example think of having a few edit text getting numbers and then some butons that do * , / ,+, – operation on them.
in addition is that possible to use results of an onCliclListener in another one? How?
Implement onClickListener in your activity.
Declare your variables as field of activity class, like
Set setOnClickListener(this); to each of your button.
in onClick method, do following: