2011-11-23 4 views
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); 
} 

답변

0

음 자세한 내용은없이 말을하는 것은 불가능하지만, 난 당신이 한 번 이상 실행되고 있지 않으면,이 if 문 중 하나만 실행할 것을 알 수 있습니다. number은 이러한 조건 중 하나 이상을 만족시킬 수 없습니다.

+0

이 코드는 for-loop 안에 있으며 if-then-else를 사용하지 않으므로이 if 문을 모두 실행해야합니다. – bytebiscuit

+0

그건 for 루프 조건에 달려 있습니다. – kcoppock

+0

괜찮아, 지금 일하고있어 !! – bytebiscuit

관련 문제