//this code shows a calendar in a dialog, hope it helps you
LayoutInflater inflater =(LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LinearLayout ll = (LinearLayout)inflater.inflate(R.layout.calendar, null, false);
CalendarView cv = (CalendarView) ll.findViewById(R.id.calendarView);
cv.setBackgroundColor(Color.BLACK);
cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
// TODO Auto-generated method stub
Log.d("date selected", "date selected " + year + " " + month + " " + dayOfMonth);
int rows = showMapFragment(year, month, dayOfMonth);
if (rows == 0){
Toast.makeText(getApplicationContext(), year + "/" + (month + 1) +"/" + dayOfMonth + " No route to display", Toast.LENGTH_SHORT).show();
}
}
});
ll.findViewById(R.id.calendarView).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d("calendar view", "calendar view clicked");
}
});
Dialog calendarDialog = new Dialog(Main.this);
calendarDialog.setContentView(ll);
calendarDialog.setTitle("Pick a date to view your performance and route");
calendarDialog.show();
//the following is the calendar layout xml file
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<CalendarView
android:id="@+id/calendarView"
android:layout_width="match_parent"
android:layout_height= "400dp"
android:showWeekNumber="false"
android:clickable="true"
android:weekDayTextAppearance="@style/calendarStyle"
android:dateTextAppearance="@style/calendarStyle"
/>
</LinearLayout>