I am working on an android application that people will enter into their accounts. I have an EditText that people enter the amount.
What I want to do is, for example, if a person enters "2", he should be automatically converted to "0.02". Then, if he wants to enter $ 22, he must press the buttons 2, 2, 0 and 0. It will be so "22.00". How do I do this using EditText. Can you give me a couple of guys?
Here are the related code snippets:
<EditText android:id="@+id/amount" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dip" android:layout_marginTop="5dip" android:inputType="number" android:hint="@string/enter_amount" android:singleLine="true" /> EditText payment = (EditText) findViewById(R.id.amount); if (payment.getText().toString().length() > 0){ total_amount =Integer.parseInt(payment.getText().toString()) ; }
source share