Skip to content

Commit

Permalink
set value
Browse files Browse the repository at this point in the history
  • Loading branch information
LikhanovD committed Oct 28, 2020
1 parent 9d1d4ea commit 40c3730
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
tools:context=".MainActivity">

<ru.vvdev.phonemask.ui.PhoneView
android:id="@+id/phoneView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="50dp"
Expand Down
6 changes: 6 additions & 0 deletions phonemask/src/main/java/ru/vvdev/phonemask/ui/PhoneView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ class PhoneView @JvmOverloads constructor(
.trim()
}

fun setValue(value: String) {
val text = value.replace(Regex("[^0-9.]"), "")
editText.text.delete(1, editText.length())
for (i in text.indices) editText.text.append(text[i].toString())
}

override fun formatChanged(format: Format) {
context?.let {
it.getDrawableForFormat(format)?.let {
Expand Down

0 comments on commit 40c3730

Please sign in to comment.