SudiptaforAndroid SudiptaforAndroid - 1 year ago 72
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?

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download