2
I have a Json that returns the values of positive and negative, and that sets the text in mine TextView
. This is the calculation I try to do, but it returns a invalid double
:
public double num1,num2,resultado;
saldo = (TextView) findViewById(R.id.saldouser);
negativo = (TextView) findViewById(R.id.vendaliv);
positivo = (TextView) findViewById(R.id.compraliv);
date = (TextView) findViewById(R.id.datatrans);
num1 = Double.parseDouble(positivo.getText().toString());
num2 = Double.parseDouble(negativo.getText().toString());
resultado = num1-num2;
System.out.println(resultado);
saldo.setText(resultado);
The mistake is:
Caused by: java.lang.Numberformatexception: Invalid double: ""
Could you leave the complete error in the question? It is better for those who answer, understand what is happening.
– Francisco
I made the edit, I inserted the error ..
– Thiago