Calendar date = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");
curDate = sdf.format(date.getTime());
Run Code Online (Sandbox Code Playgroud)
我在onCreate方法中完成了上面的代码.但它只能返回当前日期.我想要的是在日历中选择日期.
<CalendarView
android:id="@+id/calendarView1"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Run Code Online (Sandbox Code Playgroud)
请帮我
Rav*_*ndu 10
我用CalendarView而不是日历,它现在正在工作.
calendarView.setOnDateChangeListener(new OnDateChangeListener() {
@Override
public void onSelectedDayChange(CalendarView view, int year, int month,
int dayOfMonth) {
int d = dayOfMonth;
curDate =String.valueOf(d);
}
});
Run Code Online (Sandbox Code Playgroud)