我正在使用谷歌示例使用对话框片段在我的应用程序中插入一个日期选择器
http://developer.android.com/guide/topics/ui/controls/pickers.html
但是我不确定如何在设置之后获得日期(不是java专家).对话框和日期选择器运行正常,我可以记录该日期是否已正确设置但是,如何才能在父活动上执行回调?
这是我的Dialog片段
public class DatePickerFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Use the current date as the default date in the picker
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);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
**Log.w("DatePicker","Date = " + …Run Code Online (Sandbox Code Playgroud)