
- Forum posts: 5
Jan 11, 2019, 9:21:24 PM via Website
Jan 11, 2019 9:21:24 PM via Website
There are no errors in the android studio, the application crashes. What I do wrong. . It happened when I inserted a part of the color change code. Here's the code:
public void buttonClickedIzracunaj(View v) {
EditText visina = (EditText) findViewById(R.id.txtVisina);
EditText tezina = (EditText) findViewById(R.id.txtTezina);
TextView rezultat = (TextView) findViewById(R.id.txtRez);
if (visina.getText().length() == 0 && tezina.getText().length() == 0) return;
double vi = Double.parseDouble(visina.getText().toString());
double te = Double.parseDouble(tezina.getText().toString());
double ITM = te / ((vi / 100) * (vi / 100));
rezultat.setText(String.format("%.2f", ITM));
String value = rezultat.getText().toString();
int i = Integer.parseInt(value);
if(i<20){
rezultat.setTextColor(Color.parseColor("blue"));
}else if(i<=20 && i<25){
rezultat.setTextColor(Color.parseColor("green"));
}else if(i>25){
rezultat.setTextColor(Color.parseColor("red"));
}