目前我正在使用下面的代码,我可以获得在文本字段中显示的当前日期。但是我不知道如何显示选定的日期。
我还使用了 DatePicker,它可以很好地显示选定的日期,但我更喜欢 CalendarView。谢谢
Calendar c = Calendar.getInstance();
SimpleDateFormat ss = new SimpleDateFormat("dd-MM-yyyy");
Date date = new Date();
String currentdate= ss.format(date);
TextView editText = (TextView) this.findViewById(R.id.textfield1);
editText.setText(currentdate);
最佳答案
在 onCreate 中:
CalendarView v = new CalendarView( this );
v.setOnDateChangeListener( new CalendarView.OnDateChangeListener() {
public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
this.calendar = new GregorianCalendar( year, month, dayOfMonth );
}//met
});
关于android - 如何从 CalendarView 中提取日期并显示所选日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10339808/