오류코드 중요부분 입니다
01-27 13:38:12.434 10939-10939/com.ourincheon.smartcampus1231 E/AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setTextColor(int)' on a null object reference
01-27 13:38:12.434 10939-10939/com.ourincheon.smartcampus1231 E/AndroidRuntime: at com.ourincheon.smartcampus1231.haksa.CalendarView.drawCalendar(CalendarView.java:88)
01-27 13:38:12.434 10939-10939/com.ourincheon.smartcampus1231 E/AndroidRuntime: at com.ourincheon.smartcampus1231.haksa.CalendarView.init(CalendarView.java:62)
오류가 난다고 쓰여있는 코드들입니다
먼저 calenderview
public void drawCalendar() {
for (int i = 0; i < mItems.size(); i++) {
int curRowPosition = (int) i / 7;
int date[] = adapter.getDate(i);
if (i % 7 == 0) {
LinearLayout row = new LinearLayout(context);
row = (LinearLayout) inflater.inflate(R.layout.calendar_item,
null);
this.addView(row);
rows.add(row);
}
int dayId = getResources().getIdentifier(
"id/day" + Integer.toString(i - curRowPosition * 7), "id",
"com.ourincheon.smartcampus123");
int barsId = getResources().getIdentifier(
"id/bar" + Integer.toString(i - curRowPosition * 7), "id",
"com.ourincheon.smartcampus123");
TextView day = (TextView) rows.get(curRowPosition).findViewById(
dayId);
LinearLayout barLayout = (LinearLayout) rows.get(curRowPosition)
.findViewById(barsId);
day.setTextColor(Color.rgb(102, 102, 102));
if (date == null) {
day.setBackgroundColor(Color.rgb(160, 160, 160));
day.setTextColor(Color.WHITE);
if (i % 7 == 0)
day.setBackgroundColor(Color.rgb(245, 149, 115));
if ((i + 1) % 7 == 0)
day.setBackgroundColor(Color.rgb(142, 141, 177));
barLayout.setVisibility(View.GONE);
} else {
if (date[1] != month) {
if (i % 7 == 0)
day.setTextColor(Color.argb(175, 245, 149, 115));
else if ((i + 1) % 7 == 0)
day.setTextColor(Color.argb(175, 142, 141, 177));
else
day.setTextColor(Color.argb(175, 160, 160, 160));
}
else if (i % 7 == 0)
day.setTextColor(Color.rgb(245, 149, 115));
else if ((i + 1) % 7 == 0)
day.setTextColor(Color.rgb(142, 141, 177));
else
day.setTextColor(Color.rgb(102, 102, 102));
}
day.setText(mItems.get(i));
day.setGravity(Gravity.RIGHT);
}
다음으로 HaksaActivity
public void init(){
for(int i=0 ; i<12 ; i++) {
if(i==0) {
month1 = (LinearLayout) findViewById(R.id.month1);
CalendarView calendar = new CalendarView(context, i,
today.get(GregorianCalendar.YEAR), getMonthlyScheduleList(i));
((LinearLayout) month1).addView(calendar);
}
}
돠주세염....