问题
I want to make a custom date picker in Android which will only show weekdays i.e. Monday to Friday, skipping week-end. looking for some help to start with.
回答1:
Take a look at this project.
In this case he only removed Sundays but you can adjust it to remove Saturdays also, like this:
if (choosenDate.get(Calendar.DAY_OF_WEEK) ==
Calendar.SUNDAY || Calendar.DAY_OF_WEEK) ==
Calendar.SATURDAY ||
now.compareTo(choosenDate) < 0) {
dateTextView.setTextColor(
Color.parseColor("#ff0000")
);
((Button) dialog.getButton(
AlertDialog.BUTTON_POSITIVE))
.setEnabled(false);
}
Hope it helps.
*he just prevented the user from choose them, but I think you can hide it like this inside your if:
dateTextView.setVisibility(View.GONE);
来源:https://stackoverflow.com/questions/19643493/android-how-to-avoid-weekend-from-android-default-date-picker