SoFunction
Updated on 2025-03-11

Android Textview text monitoring (How to use Textview)


mobile_et.addTextChangedListener(textWatcher);

    /**
* Monitor the mobile phone number entered by the user in real time, and after entering it to the last digit, calculate the amount after the discount
     */
    TextWatcher textWatcher = new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // 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 afterTextChanged(Editable s) {
            if(() == 11){
String amountYuan = amount_et.getText().toString();//Amount selected by the user + yuan
                String mobileNum = mobile_et.getText().toString().trim();
                int tMobile = (mobileNum);

                String disAmount= getDisAmount(tMobile, amountYuan);
                amount_discount_tv.setText(disAmount);
            }
        }
    };