Example usage for android.widget DatePicker setSpinnersShown

List of usage examples for android.widget DatePicker setSpinnersShown

Introduction

In this page you can find the example usage for android.widget DatePicker setSpinnersShown.

Prototype

@Deprecated
public void setSpinnersShown(boolean shown) 

Source Link

Document

Sets whether the spinners are shown.

Usage

From source file:me.tipi.kiosk.ui.fragments.IdentityFragment.java

/**
 * Style date picker./*  w ww.  j a  v a 2 s .c o m*/
 *
 * @param datePicker the date picker
 */
private void styleDatePicker(DatePicker datePicker) {
    datePicker.setCalendarViewShown(false);
    datePicker.setSpinnersShown(true);
    LinearLayout llFirst = (LinearLayout) datePicker.getChildAt(0);
    LinearLayout llSecond = (LinearLayout) llFirst.getChildAt(0);
    for (int i = 0; i < llSecond.getChildCount(); i++) {
        NumberPicker picker = (NumberPicker) llSecond.getChildAt(i); // NumberPickers in llSecond
        Field[] pickerFields = NumberPicker.class.getDeclaredFields();
        for (Field pf : pickerFields) {
            if (pf.getName().equals("mSelectionDivider")) {
                pf.setAccessible(true);
                try {
                    pf.set(picker, ContextCompat.getDrawable(getActivity(), R.drawable.picker_divider));
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (Resources.NotFoundException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
                break;
            }
        }
    }
}