0
내 편집보기에 글자 수를 어떻게 얻을 수 있습니까? 이 번호를 확인하려면 3을 더 쓸 때 alertdialog를 사용하고 싶습니다. 나는 이것을 어떻게 간단하게 할 수 있는가?EditText 및 문자 가져 오기
내 편집보기에 글자 수를 어떻게 얻을 수 있습니까? 이 번호를 확인하려면 3을 더 쓸 때 alertdialog를 사용하고 싶습니다. 나는 이것을 어떻게 간단하게 할 수 있는가?EditText 및 문자 가져 오기
사용 TextWatcher
:
private CharSequence temp;
mEditText = (EditText)findViewById(R.id.ET);
mEditText.addTextChangedListener(mTextWatcher);
TextWatcher mTextWatcher = new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int arg1, int arg2,
int arg3) {
temp = s;
}
@Override
public void onTextChanged(CharSequence s, int arg1, int arg2,
int arg3) {
}
@Override
public void afterTextChanged(Editable s) {
// check here length of text in EditText after change
if (temp.length() > 3) {
// your alertdialog
}
}
};
이 경우 TextWatcher를 사용해야합니다.
yourEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before,
int count) {
// TODO Auto-generated method stub
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});
양을 추적 및 경고를 표시하는 방법 중 하나를 사용하는 것처럼 글고 치기에 문자를 계산에 적용