Edittext-Picker
Edittext-Picker copied to clipboard
EditText/MaskText library use for empty, masking, pattern, and range validation📱📋
EditTextPicker/Masked-Edittext Library
Edittext library by which you can easily achieve lot of functionalities though directly implemented some lines of code in XML and on Java side. Following are the functions that EditTextPicker provides:
- Empty checking
- Masking Edittext
- Pattern checking
- Range checking
Description:
Please see the description of this library in my article Edittext Picker Library
Result
Implementation
In project.gradle add this code it in root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Now, add the dependency in app.gradle:
dependencies {
implementation 'com.github.AliAzaz:Edittext-Library:X.X.X'
}
Quick Usage
XML
Note: By default required is true. But if you don't want to validate specific edittext then simply set it to false: app:required="false"
-- Required Edittext
<com.edittextpicker.aliazaz.EditTextPicker
android:id="@+id/txtBoxReq"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:required="true" />
-- Range (5-10) with default value of 999
<com.edittextpicker.aliazaz.EditTextPicker
android:id="@+id/txtBoxRange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
app:defaultValue="999"
app:maxValue="10"
app:minValue="5"
app:required="true"
app:type="range" />
-- Masking
<com.edittextpicker.aliazaz.EditTextPicker
android:id="@+id/txtMask"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
app:mask="##-##-####"
app:required="false" />
-- Pattern with default value checking [Following pattern is: (2-4)Characters with (3-5)Digits ]
<com.edittextpicker.aliazaz.EditTextPicker
android:id="@+id/txtBoxDefault"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:defaultValue="null"
app:pattern="[^0-9]{2,4}[0-9]{3,5}"
app:required="true"
app:type="equal" />
Java/Kotlin
Implement this code in submit button click
--- For Required component
if (!txtBoxReq.isEmptyTextBox()) return;
-- For validating range component
if (!txtBoxRange.isRangeTextValidate()) return;
-- For validating pattern component
if (!txtBoxDefault.isTextEqualToPattern()) return;
Support Builder Pattern
This library also support chain request
txtPicker = EditTextPicker(this,
EditTextPickerItems().apply {
setRequired(true)
setRangeValues(0.5f, 40.0f)
setMask("##.##")
setPattern("^(\\d{2,2}\\.\\d{2,2})$")
}.create())
.apply {
hint = "##.##"
inputType = InputType.TYPE_CLASS_NUMBER
}
Set values at Run time
User can easily set the attributes values in code file.
txtDate.setMask("##-##-####").setRequired(false)
CONNECT👍
LICENSE
Distributed under the MIT license. See LICENSE information.