Android(Java):onChange效果实现

private void initView(View view) {
  // TODO Auto-generated method stub
  mTvNotify = (TextView) view.findViewById(R.id.feedback_tv);
  mEtContent = (EditText) view.findViewById(R.id.feedback_edit);
  mEtContent.addTextChangedListener(watcher);
  
  mBtnSubmit = (Button) view.findViewById(R.id.submit);
  mBtnSubmit.setOnClickListener(btnClickListener);
  params = new HashMap<String, String>();
 }
 
 private TextWatcher watcher = new TextWatcher(){

  @Override
  public void beforeTextChanged(CharSequence paramCharSequence,
    int paramInt1, int paramInt2, int paramInt3) {
   // TODO Auto-generated method stub
   
  }

  @Override
  public void onTextChanged(CharSequence paramCharSequence,
    int paramInt1, int paramInt2, int paramInt3) {
   // TODO Auto-generated method stub
   
  }

  @Override
  public void afterTextChanged(Editable paramEditable) {
   // TODO Auto-generated method stub
   mTvNotify.setText("还可以输入"+(200-paramEditable.length())+"字");
  }
 };

你可能感兴趣的:(android,EditText,onChange效果)