在我的应用程序中,我使用了日期时间选择器。当我在日期选择器上单击取消按钮时,选择器对话框显示我不想要的。当我点击取消按钮时,日期选择器应该解雇它不应该去时间选择器对话框。任何人都可以帮我这个吗? 当我在模拟器上执行时,只显示设置按钮,但在设备上执行时,设置按钮和取消按钮都显示我无法找到问题所在。
@SuppressLint("ValidFragment")
public class DatePickerFragment extends DialogFragment implements
DatePickerDialog.OnDateSetListener {
public EditText activity_edittext;
public DatePickerFragment(EditText edit_text) {
activity_edittext = edit_text;
}
@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);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {
Log.d("date",String.valueOf(day) + "/"
+ String.valueOf(month + 1) + "/" + String.valueOf(year));
activity_edittext.setText(String.valueOf(day) + "/"
+ String.valueOf(month + 1) + "/" + String.valueOf(year));
}