How to use EditText onTextChanged event when I press the number?

前端 未结 6 555
自闭症患者
自闭症患者 2020-11-30 06:40

I have an EditText with \"text = 0.00\". When I press the number 3, it should be like 0.03 and the second time when I press the number

6条回答
  •  -上瘾入骨i
    2020-11-30 06:58

    You can also try this:

    EditText searchTo = (EditText)findViewById(R.id.medittext);
    searchTo.addTextChangedListener(new TextWatcher() {
        @Override
        public void afterTextChanged(Editable s) {
            // TODO Auto-generated method stub
        }
    
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
            // TODO Auto-generated method stub
        }
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            doSomething();
        } 
    });
    

提交回复
热议问题