开发者

How to run code when exactly 4 digits/letters have been entered in a 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜