Search code examples
androidandroid-datepicker

How to connect a simple page or document with datepicker for Android


When I will click a specific date from date picker Calendar then a page will be displayed. How it will be possible?

Thanks in advance


Solution

  • You start your dialog or whatever with your date picker. The XML for implementing a datepicker will look something like this:

    <DatePicker
        android:id="@+id/datePicker1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </DatePicker>
    

    You wait until the user has finished and then you go and get your calendar value from your date picker by using something like

    DatePicker d = (DatePicker) dialog.findViewById(R.id.datePicker1);
    Calendar cal = Calendar.getInstance();
    cal.set(d.getYear(), d.getMonth(), d.getDayOfMonth());
    

    You present that calendar value to the activity which displays your page and in that activity you go and find out what exactly you wish to display for that specific date.