Search This Blog

Saturday, June 11, 2016

EditText - Sự kiện con trỏ di chuyển addTextChangedListener

editTextTenDangNhapTrangDangNhap.addTextChangedListener(new TextWatcher() {
    public void onTextChanged(CharSequence s, int start, int before,
                              int count) {
        if(count==1){
            editTextTenDangNhapTrangDangNhap.setBackgroundResource(R.drawable.custom_edittext_trangdangnhap);
        }
    }
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after) {
    }
    public void afterTextChanged(Editable s) {
        if(s.length()==0){
            editTextTenDangNhapTrangDangNhap.setBackgroundResource(R.drawable.custom_edittext_trangdangnhap_error);
        }
    }
});

No comments:

Post a Comment