을의 설정 형식 :
yourEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String typedNum = yourEditText.getText().toString();
if(typedNum.length() == 3)
{
yourEditText.setText(typedNum + "-");
yourEditText.setSelection(4);
}
else if(typedNum.length() == 7)
{
yourEditText.setText(typedNum + "-");
yourEditText.setSelection(8);
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
@Override
public void afterTextChanged(Editable s) {
}
});
그렇지 않으면 그렇습니다 기술인 것은 다음과 같습니다
import android.telephony.PhoneNumberFormattingTextWatcher;
에서 OnCreate :
yourEditText.addTextChangedListener(new PhoneNumberFormattingTextWatcher());
사용자가 전화 번호를 입력 한 후 숫자의 형식을 좋아한다면 :
import android.telephony.PhoneNumberUtils;
에서 OnCreate :
을
PhoneNumberUtils.formatNumber(Editable text, int defaultFormattingType);
sharma 에뮬레이터에서 작동하지만 장치 설정이 휴대 전화에서 작동하지 않는 경우 – kumar
편집 된 답변을 참조하십시오. 귀하의 요구 사항에 대한 해결 방법을 만들었습니다. 나는 그것이 당신을 도울 것이기를 바랍니다. –
죄송합니다,이 질문의 제목을 읽었습니까? 나는 네 대답이 예상 한 것 같지 않아. –