edt_phoneNum.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
if (s.length() <= 0) {
timeBtn.setFocusable(false);
timeBtn.setBackgroundResource(R.color.lightgray);
}
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (s.length() > 0) {
timeBtn.setFocusable(true);
timeBtn.setBackgroundResource(R.color.red);
} else {
timeBtn.setFocusable(false);
timeBtn.setBackgroundResource(R.color.lightgray);
}
}
@Override
public void afterTextChanged(Editable s) {
}
});
Android EditText 内容变化监听器
最新推荐文章于 2023-05-04 11:39:26 发布