本文介绍了我怎样才能提取日期从CalendarView和显示选定的日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我使用低于code,我可以得到当前日期的文本字段中dispalyed。不过,我不知道如何显示所选日期。

我也用的DatePicker并显示选定的日期正常,但是我想preFER CalendarView。谢谢

 日历C = Calendar.getInstance();
        SimpleDateFormat的SS =新的SimpleDateFormat(DD-MM-YYYY);
        日期日期=新的日期();
        字符串的currentdate = ss.format(日期);
        TextView的EDITTEXT =(TextView中)this.findViewById(R.id.textfield1);
        editText.setText(的currentdate);
 

解决方案

在的onCreate:

  CalendarView V =新CalendarView(本);
 v.setOnDateChangeListener(新CalendarView.OnDateChangeListener(){
    公共无效onSelectedDayChange(CalendarView来看,INT年,月整型,诠释DAYOFMONTH){
       this.calendar =新的GregorianCalendar(年,月,DAYOFMONTH);
    } //满足
 });
 

Currently I am using code below and I can get current date to be dispalyed in Text field. However I have no idea how to display selected date.

I also used DatePicker and it displays selected date fine, however I would prefer CalendarView. Thanks

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);
解决方案

in 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
 });

这篇关于我怎样才能提取日期从CalendarView和显示选定的日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 17:10