監聽輸入框
阿新 • • 發佈:2019-02-08
/** * 輸入框監聽 */ private void initEdtTxt() { edtTxtDescribe.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { String content = edtTxtDescribe.getText().toString(); if (content.length() > 0) { int size = 120 - content.length(); tvCount.setText(size + ""); } else { tvCount.setText("120"); } if (content.length() == 120) { IToast.showShort(BuyerRateActivity.this, "不能再輸入"); } } @Override public void afterTextChanged(Editable s) { } }); }