tomislav-b
7/30/2014 - 10:55 AM

Shows a dialog with a CalendarView and negative/positive buttons.

Shows a dialog with a CalendarView and negative/positive buttons.

  private void showCalenderViewDialog(View.OnClickListener onPositiveChoice) {
        final Dialog dialog = new Dialog(FrontpageActivity.this);
        CalendarView cal;
        Button positive;
        Button negative;

        dialog.setContentView(R.layout.dialog_date_picker);

        cal = (CalendarView) dialog.findViewById(R.id.calendar);
        positive = (Button) dialog.findViewById(R.id.button_confirm);
        negative = (Button) dialog.findViewById(R.id.button_cancel);

        cal.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {

            @Override
            public void onSelectedDayChange(CalendarView view, int year, int month,
                                            int dayOfMonth) {
                // TODO: 
            }
        });

        positive.setOnClickListener(onPositiveChoice);
        negative.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dialog.dismiss();
            }
        });

        dialog.show();
    }