Bom dia amigos, estou tentando converter 2 array de string para 2 numeros e depois somar os dois, e o resultado ir para um textview, mas devo estar fazendo algo errado, alguem poderia me ajudar ?
Desde já obrigado…
private void ativaTimer(){
task = new TimerTask() {
public void run() {
handler.post(new Runnable() {
public void run() {
//Log.w("Data Atual", simpleFormat.format( new Date( System.currentTimeMillis())));
Date tempoAtual = new Date();
Htotal = (new SimpleDateFormat("HH:mm").format(tempoAtual));
try {
Htotal = String.valueOf(diferencaTempo(Hinicio,Htotal));
Log.w("Tempo Atual", Htotal);
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//txtValor.setText(String.valueOf(diferencaTempo(Hinicio,Htotal)));
//Pega valores dos spinners tarefa e visita
String svTarefa = sptarefa.getSelectedItem().toString();
String svVisita = spvisita.getSelectedItem().toString();
String[] sTarefa = svTarefa.split(" - ");
String vTarefa = sTarefa[1];
String[] sVisita = svVisita.split(" - ");
String vVisita = sVisita[1];
Log.w("Valor Atual", vTarefa+vVisita);
Toast.makeText(getBaseContext(), vTarefa+vVisita, Toast.LENGTH_SHORT).show();
//vVisita = vVisita.replace(".", ",");
//vTarefa = vTarefa.replace(".", ",");
Log.w("Valor Atual2", vVisita);
Log.w("Valor Atual3", vTarefa);
//AQUI TA O PROBLEMA
double num1 = Double.parseDouble(vTarefa);
double num2 = Double.parseDouble(vVisita);
double resultado = num1+num2;
//AQUI TA O PROBLEMA
Log.w("Valor Atual1", String.valueOf(resultado));
//txtValor.setText(String.valueOf(total1));
}
});
}};
//Executa o metodo run() a cada 3 segundos
timerAtual.schedule(task, 3000, 3000);
}