• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps edittext box to include currency

Hi, Im a newcomer to creating android apps. I have started to pick up some basics but would like to know a way of adding a text view box and make it add as currency. I've currently added one like so

android:id="@+id/editText4"
android:inputType="numberDecimal"

Also if i add 3 boxes with numbers in is there a way to be able to add them up in a 4th box? I hope that makes sense
 
It seems there is no way to specify a currency format in XML, but you can do so programattically using:

Code:
TextView tv = ...;
double monies = Double.parseDouble(tv.getText().toString());
NumberFormat format = NumberFormat.getCurrencyInstance();
String moneyStr = baseFormat.format(monies);
tv.setText(moneyStr);

EDIT: As per your second question, no, XML is a markup language, it is not capable of performing operations. You will need to programmatically add the content of the 3 boxes.
 
Back
Top Bottom