java 如何在 android 日历视图中仅显示当前月份

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16481504/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 23:06:05  来源:igfitidea点击:

How to Show Only Current Month in android Calendar view

javaandroidcalendar

提问by user2244658

Show Only Current month in Calendar View Android (or) Either Disable the Scroll View in Calendar View .......

在 Android 日历视图中仅显示当前月份(或)在日历视图中禁用滚动视图.......

Code for Displaying Calendar that i have written

我编写的用于显示日历的代码

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

How Can I Show Only Current Month.....?Please Help Me Guys Thanks In Adcance.

我怎样才能只显示当月.....?请帮助我,谢谢。

采纳答案by jcaruso

Whithin your class you can show all the way up to the end of the current month with:

在您的课程中,您可以一直展示到本月底:

//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); 

I don't beleive your android:scrollbars="none"is doing anything for you.

我不相信你android:scrollbars="none"正在为你做任何事。

You could also try something like this one .

你也可以尝试这样的事情一个