title: Need checkbox to allow button to be pressed - IF not working
body: <p>I made a button to open a date and time picker, but a CheckBox must be checked in order to activate my button. Without the checkbox, it works fine, with the chekbox checked or unchecked, it's not opening the date picker. Can you tell me why?</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState)
  {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_new);
      getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  
      pick_date = (Button) findViewById(R.id.pick_date);
      tv_result = (TextView) findViewById(R.id.tvdate_result);
      CheckBox fixed_date_flag = (CheckBox) findViewById(R.id.fixed_date);
      final boolean checked = (fixed_date_flag).isChecked();
  
      if(checked){
      pick_date.setOnClickListener(new View.OnClickListener()
      {
          @Override
          public void onClick(View view)
          {
              Calendar c = Calendar.getInstance();
              year = c.get(Calendar.YEAR);
              month = c.get(Calendar.MONTH);
              day = c.get(Calendar.DAY_OF_MONTH);
  
              DatePickerDialog datePickerDialog = new DatePickerDialog(NewActivity.this, NewActivity.this, year, month, day);
              datePickerDialog.show();
          }
      });}
  }
  
  @Override
  public void onDateSet(DatePicker view, int year, int month, int dayOfMonth)
  {
      yearFinal = year;
      monthFinal = month + 1;
      dayFinal = dayOfMonth;
  
      Calendar c = Calendar.getInstance();
      hour = c.get(Calendar.HOUR);
      minute = c.get(Calendar.MINUTE);
  
      TimePickerDialog timePickerDialog = new TimePickerDialog(NewActivity.this, NewActivity.this, hour, minute, DateFormat.is24HourFormat(this));
      timePickerDialog.show();
  
  }
  
  @Override
  public void onTimeSet(TimePicker view, int hourOfDay, int minute)
  {
      hourFinal = hourOfDay;
      minuteFinal = minute;
      tv_result.setText(
              "year: " + yearFinal + "\n" +
                      "month: " + monthFinal + "\n" +
                      "day: " + dayFinal +  "\n" +
                      "hour: " + hourFinal + "\n" +
                      "minute: " + minuteFinal);
  }
  </code></pre>
  
  <p>}</p>