I have a Json that returns the positive and negative values, and set the text in my TextView
. This is the calculation I try to do, but it returns an error of 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 error is:
Caused by: java.lang.NumberFormatException: Invalid double: ""