//https://snip.uncox.com/study/227/
private void edtNumE2P(final EditText edt) {
edt.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int pstart, int pbefore, int pcount) {
for (String chr : new String[]{"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}) {
if (s.toString().contains(""+chr)) {
edt.setText(MyUtils.numE2P(edt.getText().toString()));
edt.setSelection(edt.getText().length());
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {}
});
}
//https://snip.uncox.com/study/227/
private void edtNumE2P(final EditText edt) {
edt.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int pstart, int pbefore, int pcount) {
for (char chr : "0123456789".toCharArray()) {
if (s.toString().contains(""+chr)) {
edt.setText(MyUtils.numE2P(edt.getText().toString()));
edt.setSelection(edt.getText().length());
}
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void afterTextChanged(Editable s) {}
});
}
//https://snip.uncox.com/study/227/
for (int id : new int[]{R.id.edtFullName, R.id.edtPhoneCode, R.id.edtLandlinephone, R.id.edtCellularphone, R.id.edtPostalCode, R.id.edtAddress}) {
MyUtils.edtNumE2P(((EditText) findViewById(id)));
}