SudiptaforAndroid SudiptaforAndroid - 3 months ago 22
Android Question

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

i want to allow only numbers and period(.) in a android edit text. How to do this .. can any body help?


EditText is derived from TextView which has a

void addTextChangedListener(TextWatcher watcher)

method. TextWatcher has callbacks, like

abstract void afterTextChanged(Editable s)

that you can implement in order to filter the new text to only contain numbers and period.