Android-PickerView Timepicker: How to show month name instead of number?

rvpgvaaj  于 4个月前  发布在  Android
关注(0)|答案(3)|浏览(45)

I am using the TimePicker and I would like to show the month name ("January, February"...) instead of month number (1, 2, ... ). How is it possible ?

wa7juj8i

wa7juj8i2#

ArrayList<ArrayList<String>> monthItems = new ArrayList<>();
    Calendar calendar = Calendar.getInstance();
    calendar.set(Calendar.YEAR, 2000);
    Log.i("DATE", calendar.getTime().toString());
    ArrayList<String> listHeader = new ArrayList<>();
    listHeader.add("JAN");
    listHeader.add("FEB");
    listHeader.add("MAR");
    listHeader.add("APR");
    listHeader.add("MAY");
    listHeader.add("JUN");
    listHeader.add("JUL");
    listHeader.add("AUG");
    listHeader.add("SEP");
    listHeader.add("OCT");
    listHeader.add("NOV");
    listHeader.add("DEC");

    for (int i = 0; i < 12; i++) {
        calendar.set(Calendar.MONTH, i);
        ArrayList<String> dayList = new ArrayList<>();
        for (int j = 1; j <= calendar.getActualMaximum(Calendar.DAY_OF_MONTH); j++) {
            dayList.add(String.format("%02d", j));
        }
        monthItems.add(dayList);
    }

    pvCustomLunarMonthDay = new OptionsPickerBuilder(getActivity(), new OnOptionsSelectListener() 
 {
        @Override
        public void onOptionsSelect(int options1, int option2, int options3, View v) {
//                //返回的分别是三个级别的选中位置
//                String tx = options1Items.get(options1).getPickerViewText()
//                        + options2Items.get(options1).get(option2)
//                        + options3Items.get(options1).get(option2).get(options3).getPickerViewText();
//                tvOptions.setText(tx);
//                pvCustomLunarMonthDay.set
        }
    }).build();
    pvCustomLunarMonthDay.setPicker(listHeader, monthItems);
    pvCustomLunarMonthDay.show();
epfja78i

epfja78i3#

@abiemann
@Rohitsachdeva

check out my pull request: #718

相关问题