EditText input with pattern android
问题 I am having a EditText in which I have to accept alphanumeric input from user which is specific to pattern, and hyphens '-' are inserted automatically. "XXX-XXX-XXXX" how to achieve that ? Is there any pattern tool in android ? 回答1: You can use addTextChangedListener to EditText Refer this question , which demonstrate it 回答2: You can achieve that with PatternedTextWatcher. Edit: EditText editText = (EditText) findViewById(R.id.edittext); // Add text changed listener for automatic dots