Created
June 15, 2012 08:34
-
-
Save codinguser/2935425 to your computer and use it in GitHub Desktop.
Show a DatePickerDialogFragment and handle the response from the dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
mDateTextView.setOnClickListener(new View.OnClickListener() { | |
@Override | |
public void onClick(View v) { | |
FragmentTransaction ft = getFragmentManager().beginTransaction(); | |
DialogFragment newFragment = new DatePickerDialogFragment(OnDateSetListenerFragment.this); | |
newFragment.show(ft, "date_dialog"); | |
} | |
}); | |
} | |
@Override | |
public void onDateSet(DatePicker view, int year, int monthOfYear, | |
int dayOfMonth) { | |
Calendar cal = new GregorianCalendar(year, monthOfYear, dayOfMonth); | |
mDateTextView.setText(DATE_FORMATTER.format(cal.getTime())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment