这是我的代码,需要你的帮助:)
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Calendar c = Calendar.getInstance();
public int year = c.get(Calendar.YEAR);
public int month = c.get(Calendar.MONTH);
public int day = c.get(Calendar.DAY_OF_MONTH);
return new DatePickerDialog(getActivity(), this, year, month, day);
}
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
bTnCalander.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
CallCalender();
}
});
}
public void showDatePickerDialog(View v) {
DialogFragment newFragment = new DatePickerFragment();
newFragment.show(getSupportFragmentManager(), "datePicker");
}
private void CallCalender() {
ContentValues values = new ContentValues();
Calendar cal = Calendar.getInstance();
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("minutes", METHOD_ALARM);
intent.putExtra("allDay", false);enter code here
startActivity(intent);
}
我正面临一个问题,我如何从日期选择器中获取价值,而不是之前的那个值,然后将在Intent Calender上标记。
答案 0 :(得分:0)
致电时,
return new DatePickerDialog(getActivity(), this, year, month, day);
您需要指定放置OnDateSetListener
的{{1}},这是我为您制作的示例,
this