samedi 29 août 2015

if statement and Imageview

I need to display and image according a value. but with my code only is displayed the last line.

The value is 2 to put an example, so the image to be displayed must be "srm2", but my code display the image corresponding with the value 6.

why???

 totsrmI=((int) Math.round(totsrmI));
    if (totsrmI==2) {
        colorpint.setImageResource(R.drawable.srm2);
    }
    if (totsrmI==3) {
        colorpint.setImageResource(R.drawable.srm3);
    }
    if (totsrmI==4) {
        colorpint.setImageResource(R.drawable.srm4);
    }
    if (totsrmI==5) {
        colorpint.setImageResource(R.drawable.srm4);
    }
    if (totsrmI==6) {
        colorpint.setImageResource(R.drawable.srm6);
    }

Aucun commentaire:

Enregistrer un commentaire