在下面的代码中,我有5个TextViews,其中我尝试为每个TextView设置一个复合drawable。
然而,只有在第一个上绘制了drawable!为什么,以及如何解决它??
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);
}
答案 0 :(得分:0)
没有更多的信息就不可能说,但我可以告诉你,除非这个运行不止一次,否则只会执行其中一个if
语句。 number
不可能满足其中一个以上的条件。