Ben Adams
Ben Adams

Reputation: 129

Format Android EditText as HH:MM:SS

I have an edit text in android studio, and I want to get a value for hours, minutes, and seconds from the user. How can I start with the edit text saying 00:00:00, and have the user input numbers, but leave the :'s intact?

I'd rather not ask the user to enter the semicolons themselves

Upvotes: 1

Views: 2238

Answers (1)

Amit Vaghela
Amit Vaghela

Reputation: 22945

You can use MaskedEditText

build.gradle

dependencies {
    compile 'com.vicmikhailau:MaskedEditText:2.0.3'
}

add in xml

<com.vicmikhailau.maskededittext.MaskedEditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:mask="your_mask" />

enter image description here

Upvotes: 1

Related Questions