开发者

What is the event when and edittext is updated?

开发者 https://www.devze.com 2023-02-08 05:38 出处:网络
I have and android layout with two edittexts one for Qty and one for rate and a textview for total amount. Now 开发者_StackOverflow社区what I want to do is change/update the total amount whenever the

I have and android layout with two edittexts one for Qty and one for rate and a textview for total amount. Now 开发者_StackOverflow社区what I want to do is change/update the total amount whenever the user changes the rate or quantity fields.

What is the edittext event I am looking for and can I set it from the layout xml properties like I can set OnClick?


For this you have to set addTextChangedListener() to editText. Just as below:

editText.addTextChangedListener(this);// your activity has to implement TextWatcher interface

Then you have to override this method:

@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) {
        // TODO Auto-generated method stub

    }

You can use any of this method as you need and change your relevant views text.

0

精彩评论

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