I have an EditText
with "text = 0.00"
. When I press the number 3, it should be like 0.03
and the second time when I press the number 5, the text should be 0.35
. And 35.0
, 35.09
like this. The EditText
initially has the value of 0.00
.
These are all done with the same EditText
.
How do I achieve this? I have tried using addTextChangedListener()
with TextWatcher()
.
You have selected correct approach. You have to extend the class with TextWatcher and override
afterTextChanged()
,beforeTextChanged()
,onTextChanged()
.You have to write your desired logic in
afterTextChanged()
method to achieve functionality needed by you.put the logic in
documentation on TextWatcher
Here, I wrote something similar to what u need:
You can also try this: