片段中的 showDialog(0)
showDialog(0) in Fragment
我需要在一个片段中使用这段代码:
showDialog(0);
在一个 Activity 中正常制作,但在一个片段中我已经尝试过
getActivity().showDialog(0);
但是也不行;
我使用这些代码来解决我的情况:
// Process to get Current Date
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(getActivity(),
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// Display Selected date in textbox
EditText06.setText(dayOfMonth + "/"
+ (monthOfYear + 1) + "/" + year);
}
},
year, month, day);
dpd.show();
我需要在一个片段中使用这段代码:
showDialog(0);
在一个 Activity 中正常制作,但在一个片段中我已经尝试过
getActivity().showDialog(0);
但是也不行;
我使用这些代码来解决我的情况:
// Process to get Current Date
final Calendar c = Calendar.getInstance();
year = c.get(Calendar.YEAR);
month = c.get(Calendar.MONTH);
day = c.get(Calendar.DAY_OF_MONTH);
// Launch Date Picker Dialog
DatePickerDialog dpd = new DatePickerDialog(getActivity(),
new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year,
int monthOfYear, int dayOfMonth) {
// Display Selected date in textbox
EditText06.setText(dayOfMonth + "/"
+ (monthOfYear + 1) + "/" + year);
}
},
year, month, day);
dpd.show();