A faster way to achieve comma separated amount in edittext. This library is 100% build on kotlin.
This library extends the TextInputEditText class to achieve the above desired output.
dependencies {
...
implementation 'com.github.umeriqbal97:CommaSeparatedEditText:1.0.5'
}
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
There are two attributes are added:
• isSeparateByCommas
• noOfDecimals
<com.fauji.commaseparated.widget.CommaSeparatedEditText
android:id="@+id/commaSeparatedEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:isSeparateByCommas="true"
app:noOfDecimals="2" />
Use the below functions to get your desird text from edittext.
commaSeparatedEditText.getTextWithCommas()
commaSeparatedEditText.getTextWithoutCommas()