There are probably numerous ways to do this. One way is using
NumberFormat in code as follows:
NumberFormat nf;
nf = NumberFormat.getInstance();
nf.setMaximumFractionDigits(2);
and an example of the use of the number formatter in an assignment is
as follows:
editText.setText(nf.format(number));
or
String str = nf.format(number);
Hope this helps.
On Feb 19, 2:36 pm, rmg <[email protected]> wrote:
> Hi!
>
> I'm starting to developing android applications with eclipse. I have a
> doubt about how I can limit de decimal numbers in a EditText.
> For example, I have this EditText:
> <EditText
> android:id="@+id/euroEditText"
> android:layout_width="match_parent"
> android:layout_height="wrap_content"
> android:inputType="numberDecimal">
> <requestFocus />
> </EditText>
>
> I'd like to put a limit in the decimal part of the number, ie, 2
> number maximum, so the user only can put a number like this: 3.78
> and not: 3.78888885555999
> because the euro only accept two decimal numbers.
>
> I don't know if there is an attribute that specify this or I need a
> function to solve it.
>
> Can anyone help me??
>
> Thanks a lot.
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en