Edittext변수명.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if(Edittext변수명.isFocusable() && !s.toString().equals("")) {
try{
textlength = Edittext변수명.getText().toString().length();
}catch (NumberFormatException e){
e.printStackTrace();
return;
}
if (textlength == 4 && before != 1) {
Edittext변수명.setText(et_spec_content_2.getText().toString()+".");
Edittext변수명.setSelection(Edittext변수명.getText().length());
}else if (textlength == 7&& before != 1){
Edittext변수명.setText(et_spec_content_2.getText().toString()+".");
Edittext변수명.setSelection(Edittext변수명.getText().length());
}else if(textlength == 5 && !Edittext변수명.getText().toString().contains(".")){
Edittext변수명.setText(Edittext변수명.getText().toString().substring(0,4)+"."+Edittext변수명.getText().toString().substring(4));
Edittext변수명.setSelection(Edittext변수명.getText().length());
}else if(textlength == 8 && !Edittext변수명.getText().toString().substring(7,8).equals(".")){
Edittext변수명.setText(Edittext변수명.getText().toString().substring(0,7)+"."+Edittext변수명.getText().toString().substring(7));
Edittext변수명.setSelection(Edittext변수명.getText().length());
}
}
}
@Override
public void afterTextChanged(Editable s) {
}
});