allow only number and period(.) in edit text in android

You should use the att:

android:digits="0123456789."

http://developer.android.com/reference/android/widget/TextView.html#attr_android:digits


i have set this two lines in the textedit from my your_class.xml

android:inputType="numberDecimal"
android:digits="0123456789."

the first line is for setting the keybordart (only numbers and the dot). the second line only allows predetermined characters.


Use android:inputType="numberDecimal".

EDIT: Saw that you later wrote that you want to use this as an editText for IP numbers. Don't use my solution then. For "digits" (not numbers) plus the dot this won't work.

Tags:

Android