Datepicker: How to popup datepicker when click on button and store value in textview
<pre><code> &lt;TextView
            android:id="@+id/tv_arrival"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:text="@string/arrivaldate"/&gt;

        &lt;Button
            android:id="@+id/btn_arrival"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:text="Set"/&gt;
</code></pre>

<p>I want to show datepicker popup window. I have found some examples but i am not getting it properly. I have one button and i want that when i click on button the datepicker dialog should popup and after setting the date, the date should be display in a . PLease provide me sample code or good links.</p>

<pre><code> btn_arrival.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                final Dialog setDate = new Dialog(MainActivity.this);
                setDate.requestWindowFeature(Window.FEATURE_NO_TITLE);
                setDate.setContentView(R.layout.dialog_setdate);
                setDate.show();
                DatePicker date = (DatePicker) setDate.findViewById(R.id.datePicker);
                date.setMinDate(System.currentTimeMillis() - 1000);
                Calendar calender = Calendar.getInstance();

                DatePicker.OnDateChangedListener onDateChangedListener = new DatePicker.OnDateChangedListener() {
                    @Override
                    public void onDateChanged(DatePicker view, int years, int monthOfYear, int dayOfMonth) {
                        day = dayOfMonth;
                        year = years;
                        month = monthOfYear;
                        setDate.dismiss();
                        txt_arrival.setText("Arrival Date on: " + day + "." + (month + 1) + "." + year);
                        tv_departure.setText("Departure Date on: " + (day + 1) + "." + (month + 1) + "." + year + "");
                    }
                };

                day = calender.get(Calendar.DAY_OF_MONTH);
                month = calender.get(Calendar.MONTH);
                year = calender.get(Calendar.YEAR);

                date.init(year, month, day, onDateChangedListener);

            }

        });
</code></pre>