Disable Day selection in Android DatePicker

Normally you guys know how to show date selection in Android. Yah simply you will call the DatePickerDialog anyway I will put the code here for Android beginners.

When you run this code, you will get below screen output.

android datapicker example

Do you want Spinner date selection?  

You just want to change DatePickerDialog theme as AlertDialog.THEME_HOLO_DARK.

android datepicker holo dark theme

 

Ok now we will come to our topic, how we are going to hide the day selection on DatePicker. 

The simple and easiest way

Keep in mind that  .getDatePicker() method from DatePickerDialog works on API LEVEL greater than or equal to 11.

OR we can extends DialogFragment and hide date field.

If you this code you will get below screen output

remove date from datepicker in android

I am going to share all entire source code with layout files.

activity_main.xml

MainActivity.java

once you copy this class and layout to your Android Studio project. you are ready to execute the project. you will below screenshots output.

android date selection example date hide android sample code

LearnLinky Happy Reading you feel it helps to sort out your issue don’t forget put you comments.

Add Comment