https://github.com/abhinayme/currency-edittext
A Custom EditText implementation that allows formatting of currency-based numeric inputs.
https://github.com/abhinayme/currency-edittext
android android-app android-application android-library currency edittext java
Last synced: about 1 year ago
JSON representation
A Custom EditText implementation that allows formatting of currency-based numeric inputs.
- Host: GitHub
- URL: https://github.com/abhinayme/currency-edittext
- Owner: AbhinayMe
- License: apache-2.0
- Created: 2019-01-08T09:04:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-03-26T13:27:07.000Z (over 2 years ago)
- Last Synced: 2025-04-07T19:14:26.105Z (about 1 year ago)
- Topics: android, android-app, android-application, android-library, currency, edittext, java
- Language: Java
- Size: 5.78 MB
- Stars: 94
- Watchers: 2
- Forks: 24
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[ ](https://bintray.com/abhinayme/currency-edittext/me.abhinay.input/_latestVersion)
[](https://travis-ci.org/AbhinayMe/currency-edittext)
[](https://www.apache.org/licenses/LICENSE-2.0.html)
[](https://android-arsenal.com/details/1/7448)
# Currency-Edittext
A Custom EditText implementation that allows formatting of currency-based numeric inputs.

## 💻 Installation
Add this in your app's build.gradle file:
```groovy
dependencies {
implementation 'me.abhinay.input:currency-edittext:1.1'
}
```
Or add ClapFab as a new dependency inside your pom.xml
```xml
me.abhinay.input
currency-edittext
1.1
pom
```
## Implementation Sample
XML
```
```
Code
```
CurrencyEditText etInput;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
etInput = (CurrencyEditText) findViewById(R.id.etInput);
etInput.setCurrency(Currency.USA);
etInput.setDelimiter(false);
etInput.setSpacing(false);
etInput.setDecimals(true);
//Make sure that Decimals is set as false if a custom Separator is used
etInput.setSeparator(".");
}
```
## Customizing
The following attributes can be manipulated:
- Currency by specifying the country
- Spacing between currency and value
- Delimeter
- Decimals
- Thousands Separator Symbol
### Currency
Specify the currency by setting the country of your choice.
```
etInput.Currency = Currency.MALAYSIA;
```
Currency can also be disabled by:
```
etInput.Currency = Currency.NONE;
```
#### Custom Currency/Symbol
If a custom symbol that is not included in the library is required, any string value can be used since the the `Currency` attribute expects a `String` value.
```
etInput.Currency = "TEST";
```
Which produces:
>TEST 450.00
**Note:** Currency is set to your app's Local currency by default.
### Spacing
The spacing between the currency and the value can be specified by:
```
etInput.Spacing = true;
```
**Note:** Spacing is `false` by default.
### Delimeter
The delimeter attribute allows the addition of a `.` symbol after displaying the currency.
> Rs.100
> Rp.100
**Note:** Delimeter is `false` by default.
### Decimals
Decimals can be turned off for the EditText using:
```
etInput.Decimals = false;
```
This outputs the following:
> $100,000
### Separator
The Thousands Separator can be customized as required with any custom symbol to suit the currency formats of different countries. Example: Indonesia -> 12.000.000 (Using . instead of , as the separator)
**NOTE: Decimals must be set as `false` in order avoid conflicts in getting a clean Double or Integer output**
### Getting Clean Output
A `Double` value without Commas, Currency and Decimal places can be retrieved using:
`double cleanOutput = etInput.getCleanDoubleValue();`
An `Integer` value without Commas, Currency and Decimal places can be retrieved using:
`int cleanOutput = etInput.getCleanIntValue();`