안녕하세요. 안드로이드 3.0으로 개발하는 초짜 개발자 입니다.
제가 하려는 것이요.
첨부파일과 같이 레이아웃상에 위치한 "날짜 버튼"을 누르면 팝업 비슷하게 생긴 Calendar가 보이도록하려고 하는데요.
구글링을 통하여 확인을 CalendarView를 뒤져보고, 일반 Calendar 클레스를 봐도 popupWindow 상에 붙이는 방법에 대한 내용은
없더라구요.
궂이 첨부파일 처럼 Calendar를 보여주기 위해서 CalendarView 나 PopupWindow를 사용하지 않아도 되는데요.
제가 검색해보고, 개발문서를 뒤져 보고 나서, 첨부파일과 같이 만들기에는 CalendarView 와 PopupWindow를 조합하여 사용하는게
낫지 않을까 생각을 했습니다.
제가 만든 샘플 소스는 대략 아래와 같은데요. 실제로 버튼을 눌러 실행해보면, 어플이 죽습니다.
아래의 밑줄친 부분을 주석처리하고 실행하면, popupwindow는 제대로 위치와 색깔에 맞게 잘 나옵니다.
어플이 죽지 않고, popupwindow 안에 calendar들어가서 보이도록 할수는 없을까요?
- calendarPopup.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/patient_content_calendars"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#ffffe0">
</LinearLayout>
- 버튼 누를시 이벤트
public void onBtnClick_PatientContentCalendar(View view)
{
LinearLayout calendarPopup = (LinearLayout)findViewById(R.id.patient_content_calendars);
CalendarView calendar = new CalendarView(this);
calendarPopup.addView(calendar);
View v = View.inflate(this, R.layout.patient_content_calendar, null);
PopupWindow Popup = new PopupWindow(v, 400, 350, true);
LinearLayout main_ui = (LinearLayout)findViewById(R.id.main_page_large_linear);
Popup.showAtLocation(main_ui, Gravity.CENTER, 100, 50);
}
제가 안드로이드 개발자 문서를 보니까, PopupWindow가 view 로 받을 수 가 있어서, CalendarView도 view를 상속받으므로, 사용할 수
있지 않나... 생각했는데요.
제가 분명히 잘못한 부분이 있는 것 같은데요. 잘안되네요.
혹시 아시는 분께서는 잘못된 부분좀 지적하여 주시면 감사하겠습니다.
항상 행복하세요.




아~ 어설프게 해결은 했네요.
그냥. 아래 처럼 calendarview를 넣어주니까... 제대로 나오네요.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/patient_content_calendars"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="#ffffe0">
<CalendarView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:showWeekNumber="false"
android:shownWeekCount="0" />
</LinearLayout>
그런데... 문제점이 "일요일" 왼쪽에 몇째주인지... 표시되는 숫자가 있는데... 이거 지울려고 위에 처럼
android:showWeekNumber="false"
android:shownWeekCount="0"
이렇게 주어도 없어지지가 않네요...