How to automatically fill an EditText in android

1

I have an application that calculates the total value per product of the purchase (quantity x unit value of the product).

I would like the EditText field of the total per product to automatically populate after the quantity and strong> were filled.

Someone knows how to do with an EditText or TextView this automatic process.

    
asked by anonymous 23.10.2015 / 01:55

1 answer

2

Just add a TextChangedListener in the editText quantity and unit value, something like:

quantidade.addTextChangedListener(new TextWatcher() {

    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {

    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count, int after) {

    }

    @Override
    public void afterTextChanged(Editable s) {
        //aqui você realiza os calculos que precisa e atribui o resultado
        //ao local desejado
    }
});
    
23.10.2015 / 10:36