How to make edittext in android always have 2 decimal digits regardless of the value entered by the user?

3.2k views Asked by At

I want my edittext to always have 2 decimal places at the end regardless of the value entered by the user. How to accomplish this. Tried setting it with aftertextchanged method but it goes into an infinite loop.

1

There are 1 answers

0
Rose On BEST ANSWER

Set android:inputType="numberDecimal" No predefined function to set the limit for the edittext to How many digit it should accept after the decimal point from user. We can achieve this by using TextWatcher. Please check the link given below

http://v4all123.blogspot.in/2013/05/set-limit-for-fraction-in-decimal.html