2016-08-03 2 views
-3

여기에서 [ "화요일", "목요일", "금요일", "금요일"]으로 관심을 가져 주므로이 문자열을 " daysArray를 사용하여 배열을 검사하지만 원하는 결과를 얻지 못했습니다. 고칠 수 있습니까? 이 [Ljava.lang.String;@e856c3b배열에있는 문자열과 비교하면서 텍스트 뷰의 색상을 변경하십시오.

 String daysOfInterest=map.get("daysOfinterest"); 
     Log.d("DAYS OF INTEREST",daysOfInterest); 
     String[] daysArray = daysOfInterest.split(","); 
     Log.d("DAYS",daysArray.toString()); 
     for(int i=0;i<daysArray.length;i++){ 
      if(daysArray[i].equalsIgnoreCase("sunday")){ 
       tvSunday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvSunday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("monday")){ 
       tvMonday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvMonday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("tuesday")){ 
       tvTuesday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvTuesday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("wednesday")){ 
       tvWednesDay.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvWednesDay.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("thursday")){ 
       tvThursday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvThursday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("friday")){ 
       tvFriday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvFriday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 
      } 
      if(daysArray[i].equalsIgnoreCase("saturday")){ 
       tvSaturday.setBackground(ContextCompat.getDrawable(ActivitySavedCareAlerts.this,R.drawable.style_circle_filled_green)); 
       tvSaturday.setTextColor(ContextCompat.getColorStateList(getApplicationContext(),R.color.white)); 

      } 
     } 

     return convertView; 
    } 
+0

만약에 그밖에 또 다른 것을 사용한다면 –

+0

에는 2 개의 과오가있다 –

+0

나의 실수를 보여줄 수 있습니까? – ajay110125

답변

0

처럼 daysArray 점점이 실수

1

) 당신은 루프를 어디서나 파괴되지 않습니다이있다. 그래서 그것은 i = o에서 i = 길이로 매번 갈 것이고 색상에 지정된 값은 마지막 값이 될 것입니다. if from statment

2) setClorText 메서드에서 흰색을 매개 변수로 사용하고 있습니다. 색깔을 바꾸고 싶다면 다른 색깔을 시험해보십시오

관련 문제