Simple way to convert 1000000 to 1,000,000 .
Add maven jitpack.io and dependencies in build.gradle (Project) :
// build.gradle project
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
// build.gradle app/module
dependencies {
...
implementation 'com.github.gzeinnumer:EditTextCurrency:version'
implementation 'com.google.android.material:material:1.2.0'
}First Step. Use MaterialComponents in your style :
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
</style>- Sample 1 -> Simple
TextWacher
editText.addTextChangedListener(new CurrencyConverter(editText));
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String str = editText.getText().toString();
Log.d(TAG, "onClick: " + StringTools.trimCommaOfString(str));
textView.setText(StringTools.trimCommaOfString(str));
}
});- Sample 2 -> Simple
TextWacherWithCallBack
editText.addTextChangedListener(new CurrencyConverter(editText, new CurrencyConverter.StringCallBack() {
@Override
public void realString(String value) {
textView.setText("(Real Value) : " + value + " && (Preview) : " + editText.getText().toString());
}
}));Preview For Sample 1-4:
![]() |
|---|
| Sample 1 & Sample 2 |
FullCode MainActivity & XML
- 4.0.0
- First Release
- 4.0.1
- Take Out Useless Method
- 5.0.1
- Support SDK 16
- 5.0.2
- Bug Fixing
- 5.0.3
- Bug Fixing
- 5.1.0
- Take Out CurrencyEditText & CurrencyEditTextFilledBox & CurrencyEditTextOutlinedBox
- 5.2.0
- More Simple
- 5.2.3
- Bug Fixing
- 5.2.4
- Bug Fixing
- 5.2.6
- Bug Fixing 0
You can sent your constibution to branch open-pull.
Copyright 2020 M. Fadli Zein
