I am using RedMadRobot's input-mask-android library to set input mask to EditText for entering phone numbers.
public class MainActivity extends AppCompatActivity {
static String INPUT_MASK_PHONE = "{998} [00] [000]-[00]-[00]";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EditText login = (EditText) findViewById(R.id.login);
MaskedTextChangedListener maskedTextChangedListener = new MaskedTextChangedListener(
INPUT_MASK_PHONE,
true,
login,
null,
new MaskedTextChangedListener.ValueListener() {
@Override
public void onTextChanged(boolean b, @NotNull String s) {
}
}
);
login.addTextChangedListener(maskedTextChangedListener);
login.setSelection(login.length());
}
}
I am setting '998', which should not be removed when user tries remove. Now '998' can be removed.
<EditText
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:text="998"/>
How to make '998' not removable?
Try out this sample