How to turn off CalendarView in a DatePicker?

前端 未结 5 1370
不思量自难忘°
不思量自难忘° 2020-12-03 06:53

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 vie

5条回答
  •  Happy的楠姐
    2020-12-03 07:09

    In those cases I use

    import android.os.Build;
    
    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public void someThing() {
        [...]
    
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            minDateSelector.setCalendarViewShown(false);
        }
    }
    

    I think the readability is better than using reflection and the style is better than catch and ignore exceptions. Of course the reflection thing is also working.

提交回复
热议问题