Hide Date from Date Picker

前端 未结 6 1578
谎友^
谎友^ 2020-12-18 13:16

Currently I am using date picker native one but i want to change it in such a way that i only needed month and year how to modify this my code is following



        
6条回答
  •  -上瘾入骨i
    2020-12-18 14:09

    This might work for you.. if you are doing for only English.. also can be changes according to the requirements.

    Locale.setDefault(Locale.UK);
    

    This will make date picker to appear in the form DD/MM/YYYY

    Following code removes day spiner

    LinearLayout pickerParentLayout =
    (LinearLayout) mDatePicker.getChildAt(0);
    LinearLayout pickerSpinnersHolder = (LinearLayout) pickerParentLayout.getChildAt(0);
    NumberPicker picker = (NumberPicker) pickerSpinnersHolder.getChildAt(0);
    picker.setVisibility(View.GONE);
    

提交回复
热议问题