如何关闭CalendarView在一个datepicker? [英] How to turn off CalendarView in a DatePicker?

查看:109
本文介绍了如何关闭CalendarView在一个datepicker?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的设置屏幕我有一个日期选取器窗口小部件。在设计在Eclipse中,它显示了,因为我想(3纺纱厂的DMY),但是当我测试我的设备上,我与左侧边微调和右侧的日历一个相当奇怪的观点。从来没有见过这个(!),但做一些研究,我认为我看到了CalendarView。

On my settings screen I have a date picker widget. In the designer in Eclipse, it shows as I want (3 spinners for D-M-Y) but when I test on my device, I get a rather odd view with a side spinner on the left and a calendar on the right. Never seen this before(!) but doing some research I think I'm seeing the "CalendarView".

我发现,我应该能够设置一个calendarViewShown属性假,但我的XML引发错误与此有关。我发现了一个问题就在这里,暗示API级别,无可厚非(我minSDKLevel是7,但我目标定位11这样我就可以得到操作栏按钮,而不是OLDSKOOL菜单)。 所以,我想我会尝试在code设置它:

I found that I should be able to set a "calendarViewShown" property to false- but my XML throws an error with this. I found another question on here that suggested the API level was to blame (my minSDKLevel is 7, but I'm targetting 11 so I can get the action bar button rather than the oldskool menu). So I thought I'd try setting it in code:

    int currentapiVersion = android.os.Build.VERSION.SDK_INT;
    if (currentapiVersion >= 11)
        minDateSelector.setCalendarViewShown = false;

但同样,没有发现这个没有─setCalendarViewShown。但这里的文档 说它应该存在。 任何想法?!

But again, this fails- setCalendarViewShown isn't found. But the docs here say it should exist. Any ideas?!

推荐答案

如果你的目标API的版本,你可以在你的<$ c。使用以下XML(不需要编写Java code) $ C>&LT;的DatePicker&GT; :

If you are targeting a later version of the API, you can use the following XML (no need to write Java code) in your <DatePicker>:

 android:calendarViewShown="false"

这篇关于如何关闭CalendarView在一个datepicker?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆