[Android] EditText , 空字串判斷&OnTextChangeListener
OnChangeListener
myEditText.addTextChangedListener(
new
TextWatcher() {
@Override
public
void
beforeTextChanged(CharSequence charSequence,
int
i,
int
i1,
int
i2) {
}
@Override
public
void
onTextChanged(CharSequence charSequence,
int
i,
int
i1,
int
i2) {
}
@Override
public
void
afterTextChanged(Editable editable) {
if
(myEditText.getText().length() >
0
){
// Typing
}
else
{
// Not typing
}
}
});
空字串判斷
if("".equals(mEditText.getText().toString().trim())){ //edittext輸入為空白或無輸入 }else{ //edittext有輸入 }
取得FOCUS
requestFocus();
留言
張貼留言