How can I get selected date in CalenderView in Android?

Calendar date = Calendar.getInstance();     
SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd");

curDate = sdf.format(date.getTime());

I have done the above code inside onCreate method. But it can only return the current date. What I want is to have the date selected in the calender.

<CalendarView
      android:id="@+id/calendarView1"
      android:layout_width="match_parent"
      android:layout_height="match_parent" />

Please help me

Answers


I used CalendarView instead of Calender and it's working now.

calendarView.setOnDateChangeListener(new OnDateChangeListener() {

                @Override
                public void onSelectedDayChange(CalendarView view, int year, int month,
                        int dayOfMonth) {
                    int d = dayOfMonth;
                    curDate =String.valueOf(d);
                }
            });

Need Your Help

warning … defined but not used - do I really need .c file?

c gcc static header inline

I find out that Apple uses the following declaration in OSAtomic.h header:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.