0

One of my features require the user to select a month and year, so the following is the method which will pop up the first attached image (d/m/y).

final Calendar c = Calendar.getInstance();

                        int year = c.get(Calendar.YEAR);
                        int month = c.get(Calendar.MONTH);
                        int day = c.get(Calendar.DAY_OF_MONTH);

                        DatePickerDialog dp = new DatePickerDialog(getActivity(), android.R.style.Theme_Holo_Light_Dialog_MinWidth,
                                new DatePickerDialog.OnDateSetListener() {

                                    @Override
                                    public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                                        //Check if selected month/year is in future of today. 
                                    }

                                }, year, month, day);

                        dp.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
                        dp.setTitle("Set Monthly Overview");
                        dp.show(); 

enter image description here

However, i do NOT require the date. How can i disable user from selecting it, or best of all, to even not display the date option there?

What I wish to achieve is something like the following image in the best case scenario.

enter image description here

Zhi Kai
  • 1,549
  • 1
  • 13
  • 31
  • 1
    You can read the topic to custom your UI. http://sunilsuthar02.blogspot.in/2013/04/date-picker-like-iphone-in-android.html – sonnv1368 Aug 03 '16 at 10:30
  • refer http://stackoverflow.com/questions/10673842/android-hide-date-field-in-datepickerdialog – sasikumar Aug 03 '16 at 10:31

1 Answers1

1

Refer "Android DatePicker change to only Month and Year" which will help you just display month and year in the datepicker. Hope this helps.

Community
  • 1
  • 1
Neh
  • 442
  • 4
  • 7