Friends, now the doubt is as follows, I need the "+" operation to be present to make the sum, but it always exits 1 + 2 and the two never make the sum. Anyone have any idea what it might be?
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class Inicio extends Activity {
TextView tela;
Button btnreset, btnraiz, btnporcentagem, btndesfazer,
btnsubtracao, btnum1, btnum2, btnum3,
btnsoma, btnum4, btnum5, btnum6,
btnmultiplicacao, btnum7, btnum8, btnum9,
btndivisao, btnum0, btnponto, btnresutado;
String resultado;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_inicio);
tela = (TextView) findViewById(R.id.tela);
btnreset = (Button) findViewById(R.id.reset);
btnraiz = (Button) findViewById(R.id.raiz);
btnporcentagem = (Button) findViewById(R.id.porcentagem);
btndesfazer = (Button) findViewById(R.id.desfazer);
btnsubtracao = (Button) findViewById(R.id.subtracao);
btnum1 = (Button) findViewById(R.id.um);
btnum2 = (Button) findViewById(R.id.dois);
btnum3 = (Button) findViewById(R.id.tres);
btnsoma = (Button) findViewById(R.id.soma);
btnum4 = (Button) findViewById(R.id.quatro);
btnum5 = (Button) findViewById(R.id.cinco);
btnum6 = (Button) findViewById(R.id.seis);
btnmultiplicacao = (Button) findViewById(R.id.multiplicacao);
btnum7 = (Button) findViewById(R.id.sete);
btnum8 = (Button) findViewById(R.id.oito);
btnum9 = (Button) findViewById(R.id.nove);
btndivisao = (Button) findViewById(R.id.divisao);
btnum0 = (Button) findViewById(R.id.zero);
btnponto = (Button) findViewById(R.id.ponto);
btnresutado = (Button) findViewById(R.id.resultado);
}
public void digito(View v) {
switch (v.getId()) {
case R.id.um:
resultado+=Integer.parseInt(btnum1.getText().toString());
tela.append(btnum1.getText());
break;
case R.id.dois:
resultado+=Integer.parseInt(btnum2.getText().toString());
tela.append(btnum2.getText());
break;
case R.id.soma:
resultado+=String.valueOf(btnsoma.getText().toString());
tela.append(btnsoma.getText());
break;
case R.id.resultado:
tela.append(resultado);
break;
}
}
}