Ria Ria - 16 days ago 10
Android Question

How to use EditText onTextChanged event when i press the number?

Hi am having EditText with the "text = 0.00". when i press the number 3 it should be like 0.03 & second time when i press the number 5 the text should be 0.35. And 35.0, 35.09 like this. The EditText initially having the value as 0.00.

These are all done with the same EditText.

How to achieve this.. I have tried on addTextChangedListener() with TextWatcher().

Can Anyone suggest me how to do it...

Thanks in adv.

Answer

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.