All- I have an EditText field where the user enters a currency value (eg. "120.45"). I need to take that value and use it in an equation. The problem is, the decimal point gets ignored so instead of multiplying 120.45 by 2 it multiples 12,045 by 2. Is there any way to make the equation see this value as "120.45". Here is my XML:
<EditText android:id="@+id/edit_bill"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/view_dollar_sign"
android:layout_alignBaseline="@id/view_dollar_sign"
android:padding="5dp"
android:singleLine="true"
android:hint="@string/edit_bill"
android:digits="0123456789."
android:maxLength="6"
android:gravity="right"
android:layout_alignBottom="@id/view_dollar_sign"
/>
Here is my code:
EditText text = (EditText)findViewById(R.id.edit_bill);
String value = text.getText().toString();
if(!value.contains("."))
value = "."+value;
float bill = Float.parseFloat(value);
Thanks in advance!