1. TableLayout calendar = new TableLayout (this);
2. TableLayout calendar = (TableLayout)findViewById(R.id.CalendarTable);
calendar.addView(tr);
1번처럼 코드상에서 새로 생성한 TableLayout에 addView를 하면 이상이 없는데
2번처럼 xml에 정의해 놓은 TableLayout을 불러다가 addView하면 nullpointer exception이 걸립니다.
이유가 뭘까요? 둘다 똑같은 TableLayout 아닌가요?
저도 비슷한 경우가 있었는데 후자의 경우에는 SetcontentView() 후에 addView() 하니깐 되더군요
초기화의 차이인듯합니다;
아님 말고요 ㅎ;;;