Error adding fields to Text Edit using OnFocusChangeListener

1

I'm trying to get my application to calculate the fields% cos_de% cost price plus profit percentage and when clicking on the sale price field the result will appear, however instead of appearing the result the following message appears in edit text of the field:

  

android.widget.EditText@41f

Thank you to anyone who can help as specifically as possible because I have no experience.

  OnFocusChangeListener focusListener = new View.OnFocusChangeListener() {

        public void onFocusChange(View v, boolean hasFocus) {
            if (!hasFocus) {

                custo = MonetaryMask.stringMonetarioToDouble(edPrecoDeCusto.getText().toString());
                lucro = MonetaryMask.stringMonetarioToDouble(edPercDeLucro.getText().toString());
                venda = MonetaryMask.stringMonetarioToDouble(edPrecoDeVenda.getText().toString());

                venda = calcularLucro(custo, lucro);
                edPrecoDeVenda.setText(edPrecoDeVenda.toString());

            }

        }
    };


   edPercDeLucro.setOnFocusChangeListener(focusListener);      


    private double calcularLucro(double custo, double lucro) {
             venda = custo + lucro / 100 * custo;
      return venda;
}
    
asked by anonymous 18.01.2016 / 19:26

1 answer

1

You are passing String to the object's memory reference:

edPrecoDeVenda.toString()

Try this:

 edPrecoDeVenda.setText(venda);

With getText() , you will get the value of the field!

    
18.01.2016 / 19:29