设置button没有输入按钮的状态
chongzhiBtn.setClickable(
false);
// 给 EditText 设置文本内容改变的监听
chongzhiEt.addTextChangedListener( new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
Log. i( "TAG", "ChongZhiActivity beforeTextChanged()");
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log. i( "TAG", "ChongZhiActivity onTextChanged()");
}
@Override
public void afterTextChanged(Editable s) {
// Log.i("TAG", "ChongZhiActivity afterTextChanged()");
String moneyNum = chongzhiEt.getText().toString().trim();
if (TextUtils. isEmpty(moneyNum)) { // 空
//1. 设置 Button 的背景颜色
chongzhiBtn.setBackgroundResource(R.drawable. btn_023);
//2. 设置 Button 可点击性
chongzhiBtn.setClickable( false);
} else {
//1. 设置 Button 的背景颜色
chongzhiBtn.setBackgroundResource(R.drawable. btn_01);
//2. 设置 Button 可点击性
chongzhiBtn.setClickable( true);
}
}
});
// 给 EditText 设置文本内容改变的监听
chongzhiEt.addTextChangedListener( new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
Log. i( "TAG", "ChongZhiActivity beforeTextChanged()");
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log. i( "TAG", "ChongZhiActivity onTextChanged()");
}
@Override
public void afterTextChanged(Editable s) {
// Log.i("TAG", "ChongZhiActivity afterTextChanged()");
String moneyNum = chongzhiEt.getText().toString().trim();
if (TextUtils. isEmpty(moneyNum)) { // 空
//1. 设置 Button 的背景颜色
chongzhiBtn.setBackgroundResource(R.drawable. btn_023);
//2. 设置 Button 可点击性
chongzhiBtn.setClickable( false);
} else {
//1. 设置 Button 的背景颜色
chongzhiBtn.setBackgroundResource(R.drawable. btn_01);
//2. 设置 Button 可点击性
chongzhiBtn.setClickable( true);
}
}
});