0
다음 코드에서 필자는 5 개의 TextView를 가지고 각각에 대해 복합 드로어 블을 설정하려고합니다.다른 TextViews에 복합 드로어 블을 설정할 수 있습니다.
그러나 드로어 블은 첫 번째 드로잉에서만 사용됩니다! 왜, 그리고 그것을 고치는 방법!?
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);
}
이 코드는 for-loop 안에 있으며 if-then-else를 사용하지 않으므로이 if 문을 모두 실행해야합니다. – bytebiscuit
그건 for 루프 조건에 달려 있습니다. – kcoppock
괜찮아, 지금 일하고있어 !! – bytebiscuit