在用户昵称的输入时,限定8个字符,本意是在输入超过8个时候,页面toast一个提示,就是下面的TextWatcher的监听,在afterTextChanged中处理。

原bug:huawei MT2-C00提示数组越界crash,其他手机如红米小米荣耀HtcD820t都没问题。

 @Override
             public void afterTextChanged(Editable s) {
                editStart = mUsernameEditText.getSelectionStart();
                editEnd = mUsernameEditText.getSelectionEnd();
                if (temp.length() > 8) {
                     s.delete(editStart - 1, 0, editEnd);
                     showToast("昵称最多为8个字符");
                     int tempSelection = editStart;
                     mUsernameEditText.setText(s);
                     mUsernameEditText.setSelection(s.length());
                 }
             }
         });
View Code

相关文章:

  • 2022-12-23
  • 2021-04-29
  • 2022-12-23
  • 2022-12-23
  • 2021-06-24
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2021-12-31
  • 2021-09-09
  • 2022-12-23
相关资源
相似解决方案