2013-05-10 94 views
7

僅顯示最近一個月的日曆視圖的Android(或)或者禁用滾動查看日曆視圖.......如何,只顯示當前月在Android的Google日曆視圖

代碼顯示日曆,我有書面

<CalendarView 
     android:id="@+id/calendar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:showWeekNumber="false" 
     android:shownWeekCount="5" 
     android:scrollbars="none"/> 

如何只顯示本月.....?請幫助我你們在感謝Adcance。

+0

你是否達到了你想要做的事情? – chaitanyad 2015-06-02 12:11:02

回答

1

Whithin類,你可以顯示所有的方式,以當月的與末尾:

//get month and get how many days in current month 
Calendar calendar = Calendar.getInstance(); 
int daysInMonth = calendar.getActualMaximum(Calendar.DAY_OF_MONTH); 
cal.setMaxDate(daysInMonth); 

我不敢相信你android:scrollbars="none"是做你任何東西。

你也可以嘗試像這樣的 one

+1

仍顯示多個月,但此代碼會導致日曆從1969年開始。 – committedandroider 2016-02-01 00:21:22

相關問題