0
我檢查了多個線程,但沒有人似乎回答我的問題。從Android開發網站,我創建了一個日期選取片段:Android從datepicker獲取日期
public 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);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
public void onDateSet(DatePicker view, int year, int month, int day) {
}
}
在我的活動我只要致電:
public void showDatePickerDialog(View v){
DialogFragment dateFragment = new DatePickerFragment();
dateFragment.show(getFragmentManager(), "datePicker");
}
如何傳遞的日期從選擇器回活動的用戶挑選?基本上我只想一個文本字段設置爲日期:
mTextField.set(*The date*);