オプションメニューにこのコードがあります
Dialog dialog = new Dialog(ScheduleActivity.this);
dialog.setTitle("Add Event");
dialog.setContentView(R.layout.add_even_on);
Button datePicker = (Button) dialog.findViewById(R.id.datePicker);
final DialogFragment dateFrag = new MyDatePicker();
datePicker.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
dateFrag.show(getSupportFragmentManager(), "datePicker");
}
});
dialog.show();
オプションメニューの[イベントの追加]をクリックすると、ダイアログが表示され、DatePickerDialogを表示するボタンが表示されます。その横には、 DatePickerDialogで選択した日付を反映するTextViewがあります。これは、AndroidsDeveloperから取得したクラスです。 DatePickerDialogの使用方法。
class MyDatePicker extends DialogFragment implements DatePickerDialog.OnDateSetListener {
int pYear;
int pDay;
int pMonth;
@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) {
pYear = year;
pDay = day;
pMonth = month;
}
}
だから私の問題は、DatePickerDialogの[設定]をクリックして自動的に閉じ、DatePickerDialogを開くボタンと水曜日を反映するTextviewを含むダイアログに戻るときに、ミリ秒単位で値を取得するにはどうすればよいですか? DatePickerDialogを選択しました...DatePickerDialog内で選択したものを表示しません...
これが私の言いたいことの写真です、
したがって、[日付を選択]ボタンをクリックすると、次の図に示すようにDatePickerDialogボックスが表示されます。
[設定]をクリックすると、そのDatePickerDialogからのミリ秒単位の値を考慮したかったのです。