Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to limit EditText length to 7 integers and 2 decimal places?

Tags:

People also ask

How do I restrict the number of decimal places?

Now you can limit the decimal places. Select the number cell and in the Menu, go to Format > Number > More Formats > Custom number format.

How do I restrict two decimal places?

Rounding a decimal number to two decimal places is the same as rounding it to the hundredths place, which is the second place to the right of the decimal point. For example, 2.83620364 can be round to two decimal places as 2.84, and 0.7035 can be round to two decimal places as 0.70.

How do I limit double to two decimal places on Android?

You can use String. format("%. 2f", d) , your double will be rounded automatically.


I have an EditText box which have to allow user to enter upto 7 numbers and two decimal places. After entering seven digits,it should not allow to add one more digit but i may allow upto 2 decimal places. I use a decimal filter for 2 decimal places and this code in XML

android:maxLength="7"    
android:imeOptions="actionDone"                  
android:inputType="numberDecimal"

But EditText is allowing to enter 8 digits. How can this be solved?