0

OK. I have spent hours on this and I can't figure it out. I have created a separate Class that has the datepickerdialog fragment as follows:

public abstract class DatePickerFragment extends DialogFragment implements
    DatePickerDialog.OnDateSetListener {

    @Override
    public Dialog onCreateDialog(Bundle savedInstanceState) {

    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);


    // Create a new instance of DatePickerDialog and return it
    return new DatePickerDialog(getActivity(), this, year, month, day);
    }
}

The code that calls this fragment is:

textViewToChange.setOnLongClickListener(new OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {

            DialogFragment newFragment = new DatePickerFragment() {
                public void onDateSet(DatePicker view, int year, int month, int day) {
                                    //TODO some stuff here                          
                                    changed = true;
                }
            };

            newFragment.show(getSupportFragmentManager(), "datePicker");

            return changed;
        }
    });

I have tried everything I could read and I just can't figure out how to set the title. The title that shows up is today's date. I want to set the title and also add an icon. Any help would be great!

UFGator
  • 55
  • 7
  • 1
    http://stackoverflow.com/questions/13123445/set-datepickerdialog-title-permanently see this link ... it may helpful to you. – priyanka morisetti Jan 22 '14 at 04:12
  • Thanks for pointing me in that direction. I already tried using that one. The problem is that I don't know what to setTitle to. In that example they had a DatePickerDialog dpd and therefore just did dpd.setTitle. I don't have a DatePickerDialog object (that I know of) to reference. – UFGator Jan 22 '14 at 14:51
  • Actually I took a second look at the link you gave me. I must have been up too late last night! I made some changes and it worked. The changes were: 1. took out the statement "return new DatePickerDialog(getActivity(), this, year, month, day);" and replaced it with "DatePickerDialog dpd = new DatePickerDialog(getActivity(), this, year, month, day);" I was then able to setTitle and setIcon on "dpd". Thanks for giving me that extra push! – UFGator Jan 22 '14 at 17:11

0 Answers0