Back to project page Books.
The source code is released under:
Apache License
If you think the Android project Books listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.contender.books; // ww w . j a v a 2 s. c om import java.util.Calendar; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DialogFragment; import android.os.Bundle; /** * Implements the DatePickerFragment dialog used by {@link BookActivity} * <p> * Provides a UI for the user to set a date. * * @author Paul Klinkenberg */ public class DatePickerFragment extends DialogFragment { DatePickerDialog.OnDateSetListener mListener; @Override public void onAttach(Activity activity) { super.onAttach(activity); // Verify that the host activity implements the callback interface try { mListener = (DatePickerDialog.OnDateSetListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnDateSetListener"); } } @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker Calendar c = BookActivity.dueDate; 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(), mListener, year, month, day); } }