2015-06-13 45 views

回答

0

這對我來說是完美的工作。去嘗試一下。

private void initializeCalendar() { 
    // TODO Auto-generated method stub 
    CalendarView cvCalendar = null; 
    cvCalendar.setShowWeekNumber(false); 
    cvCalendar.setFirstDayOfWeek(1); 
    cvCalendar.setSelectedWeekBackgroundColor(getResources().getColor(
      R.color.darkgray)); 
    cvCalendar.setUnfocusedMonthDateColor(getResources().getColor(
      R.color.darkgray)); 
    cvCalendar.setWeekSeparatorLineColor(getResources().getColor(
      R.color.white)); 
    cvCalendar.setSelectedDateVerticalBar(R.color.white); 
    cvCalendar.setSelected(false); 
    cvCalendar.setOnDateChangeListener(new OnDateChangeListener() { 

     @Override 
     public void onSelectedDayChange(CalendarView view, int year, 
       int month, int day) { 
      // TODO Auto-generated method stub 
      // cvCalendar.canScrollVertically(day); 

      Calendar c = Calendar.getInstance(); 
      c.set(year, month, day); 
      month = month + 1; 

      SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 
      formattedDate = sdf.format(c.getTime()); 

     } 
    }); 

} 
相關問題