I'm writing a (what was supposed to be) quickie program to flex my unused java muscles and check out android. I'm trying to write a simple celsius to fahrenheit converter, that has 2 TextView labels for F and C, and 2 corresponding EditTexts. When a value is entered in one of the boxes and the convert Button pushed, the empty EditText is filled in with the converted value.
I've had a surprising amount of difficulty accessing my variables from inside the onClick() handler (or any other method) however. I expected to have to convert the EditText value into a string, and then to a double, but in order to reference any of the variables from onClick I've had to label them final, which has prevented me from modifying any of them.
So first of all, why is it necessary for these to be final in the first place? I haven't used Java in a while but I know this wouldn't be a problem in C. And second, how should I write this?
I've had a surprising amount of difficulty accessing my variables from inside the onClick() handler (or any other method) however. I expected to have to convert the EditText value into a string, and then to a double, but in order to reference any of the variables from onClick I've had to label them final, which has prevented me from modifying any of them.
So first of all, why is it necessary for these to be final in the first place? I haven't used Java in a while but I know this wouldn't be a problem in C. And second, how should I write this?