In the following code I have 5 TextViews in which I try to set a compound drawable for each one of them.
However the drawable is drawn only on the first one! WHY, and how to fix it !?
if(number >= 1210 && number <= 1215){
ist1_1210.setCompoundDrawablesWithIntrinsicBounds(R.drawable.update_icon, 0, 0,0);
ist1_1210.setPadding(10, 0, 0, 0);
ist1_1210.setCompoundDrawablePadding(-45);
System.out.println("ist1_1210 is supposed to be running");
}
if(number >= 1220 && number <= 1225){
//ist1_1220.setTextColor(Color.GREEN);
ist1_1220.setCompoundDrawablesWithIntrinsicBounds(R.drawable.update_icon, 0, 0,0);
ist1_1220.setPadding(10, 0, 0, 0);
ist1_1220.setCompoundDrawablePadding(-45);
System.out.println("ist1_1220 is supposed to be running");
}
if(number >= 1230 && number <= 1235){
//ist1_1230.setTextColor(Color.GREEN);
ist1_1230.setCompoundDrawablesWithIntrinsicBounds(R.drawable.update_icon, 0, 0,0);
ist1_1230.setPadding(10, 0, 0, 0);
ist1_1230.setCompoundDrawablePadding(-45);
}
if(number >= 1240 && number <= 1245){
//ist1_1240.setTextColor(Color.GREEN);
ist1_1240.setCompoundDrawablesWithIntrinsicBounds(R.drawable.update_icon, 0, 0,0);
ist1_1240.setPadding(10, 0, 0, 0);
ist1_1240.setCompoundDrawablePadding(-45);
}
if(number >= 1250 && number <= 1255){
//ist1_1250.setTextColor(Color.GREEN);
ist1_1250.setCompoundDrawablesWithIntrinsicBounds(R.drawable.update_icon, 0, 0,0);
ist1_1250.setPadding(10, 0, 0, 0);
ist1_1250.setCompoundDrawablePadding(-45);
}
Well without more information it’s impossible to say, but I can tell you that unless this is running more than once, only one of these
ifstatements will execute.numbercan’t possibly satisfy more than one of these conditions.