How to automatically fill an Edittext on android

Asked

Viewed 861 times

1

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

Wanted the field to Edittext of total per product was filled in automatically after the amount and unit value were completed.

Does anyone know how to do with a Edittext or Textview this automatic process.

  • 2

    Post the code to facilitate the galley help in your problem.

1 answer

2


Just add a Textchangedlistener in editText quantity and value unitario, 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
    }
});
  • It worked perfectly. Valeuuu Christian Beregula!!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.