How to Apply the Textchange event on EditText

前端 未结 7 1358
感动是毒
感动是毒 2020-12-13 13:38

I developed one simple app, like subtraction, addition. In this app I use three EditTexts, one for answer and other two for question. I want to calculate the answer of quest

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-13 14:22

    i think the best in case the edittext type is number... use the (length function) of parameter instead of (equle() function) ex:

    edittext.addTextChangedListener(new TextWatcher() {
    
        public void onTextChanged(CharSequence s, int start, int before,
                int count) {
            if (s.length() > 0)
                    { //do your work here }
            }
    
        }
    
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
    
        }
    
        public void afterTextChanged(Editable s) {
    
        }
    });
    

提交回复
热议问题