Make A Variable Final In Android Studio
When I try to make the variable A(String) equal to e(Which comes from a Plain Text) this appears in the line of the error(In the code below): Variable 'e' is accessed from within i
Solution 1:
You are trying to add a string to an EditText:
A=""+e;
This can't be done.
You probably want to add a string to a string, instead:
A = "" + e.getText().toString();
Solution 2:
You can't assign e to a, since e is an edittext while a is a String. This is a java problem, and I recommend you learning java from thenewboston's tutorials before getting into android. Anyway, you need to use
A = e.getText();
No need for final variables, which use the final keyword.
Using a final keyword here, would cause problems. A final variable can't be edited, and won't be a solution since the variable will hold a text representation of that EditText, not it's actual text. Just for the sake of completeness, though, a final variable is represented like this:
final String finalString = "This string will now for ever hold this value. This can't be changed.";
Post a Comment for "Make A Variable Final In Android Studio"