Avinash Sahu
Avinash Sahu

Reputation: 249

EditText with only digits. No Decimal Point

I want to have an EditText which only allows numeric inputs. It should not allow even decimal point (.) in the field.

tried

<EditText
.....
android:digits="0123456789"
android:inputType="number"
android:maxLength="4"
.....
/>

But it still accepts decimal point. Any solution to this problem ?

Upvotes: 3

Views: 1376

Answers (2)

Wasif Hamdani
Wasif Hamdani

Reputation: 148

This works:

  android:inputType="number"
  android:maxLength="4"

Upvotes: 1

Giridharan
Giridharan

Reputation: 4462

Try like this..

android:inputType="number|none"
android:maxLength="3"
android:digits="0123456789"

Upvotes: 1

Related Questions