It is necessary to organize the input check in the text field by the filter.
+Х(ХХХ) ХХХ-ХХХХ
The ideal scenario is as follows. Initially, the input text looks like this:
+_ ( _ _ _ ) _ _ _-_ _ _ _ .
The user enters only the numbers and they fall into place. Those. after the first digit will be like this:
+7 ( _ _ _ ) _ _ _-_ _ _ _
Second:
+7 (4 _ _ ) _ _ _-_ _ _ _
, etc.
Help with the implementation, examples of ideas ... I found it myself: using a mask with EditText , but I can't bring it to mind.
package my.dfedorenko; import android.app.Activity; import android.os.Bundle; import android.widget.EditText; public class TestPhoneparserActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); EditText phone = (EditText)findViewById(R.id.phone); phone.addTextChangedListener(new MaskedWatcher("(###) ###-##-##")); setContentView(R.layout.main); }}