0

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.

rajvir singh
  • 111
  • 1
  • 3
  • 9
  • try https://stackoverflow.com/questions/5357455/limit-decimal-places-in-android-edittext. First search on this site then ask because these questions are already asked. – D.J Aug 25 '17 at 05:40
  • Possible duplicate of [Limit Decimal Places in Android EditText](https://stackoverflow.com/questions/5357455/limit-decimal-places-in-android-edittext) – Vishal Vaishnav Aug 25 '17 at 05:42
  • `Tried setting it with aftertextchanged method` try doing it in `onTextChanged` – Vladyslav Matviienko Aug 25 '17 at 06:12

1 Answers1

1

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

Rose
  • 176
  • 1
  • 1
  • 10