1
I’m trying to get my application to calculate the fields EditText
cost price plus profit percentage and when clicking on the sales price field the result already appears, but instead of appearing the result appears the following message in the Edit text of the field:
android.widget.Edittext@41f
Thanks to anyone who can help in the most specific way 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;
}
I did as you suggested but he is not performing the calculation. Is not giving the error but also does not perform the calculation, any suggestion ? @Thiago Luiz Domacoski
– Eduardo Krakhecke
try like this: edPrecoDeVenda.setText(sale); For you arrow the calculation in this variable, right?
– Thiago Luiz Domacoski
I edited the answer too !
– Thiago Luiz Domacoski
Thank you !! 100% @ Thiago Luiz Domacoski
– Eduardo Krakhecke