开发者

How to run code when exactly 4 digits/letters have been entered in a edittext

开发者 https://www.devze.com 2023-01-28 22:41 出处:网络
How do i make some code run when exactly 4 digits/letters have been entered in a edit开发者_StackOverflowtext?All you would need to do is add a TextWatcher to your edittext.

How do i make some code run when exactly 4 digits/letters have been entered in a edit开发者_StackOverflowtext?


All you would need to do is add a TextWatcher to your edittext.

myEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
  if(messageText.getText().length() == 4){
    //call a function here
  }
}
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号