Hello every one if any one can help it out then tell me please i'm trying a code for a datepicker in android, it is picking date from the system and showing a dialogue button which allows us to select any date as well but the problem is i want to show that new selected date on text view, how can i do this ? my code is :

package com.example.rehman_pc.datepicker;

import android.app.Activity;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;

import java.util.Calendar;

public class MainActivity extends Activity {
    final int DATE_PICKER_ID = 1111;
int year, month, day;
    TextView Output;
    Button changeDate;
        public void onCreate(Bundle savedInstanceState) {

             Output = (TextView) findViewById(R.id.viewdate);
             changeDate = (Button) findViewById(R.id.button);

            // Get current date by calender

            final Calendar c = Calendar.getInstance();
            year  = c.get(Calendar.YEAR);
            month = c.get(Calendar.MONTH);
            day   = c.get(Calendar.DAY_OF_MONTH);

            // Show current date

            Output.setText(new StringBuilder()
                    // Month is 0 based, just add 1
                    .append(month + 1).append("-").append(day).append("-")
                    .append(year).append(" "));

            // Button listener to show date picker dialog

            changeDate.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {

                    // On button click show datepicker dialog



        protected Dialog onCreateDialog(int id) {
            switch (id) {
                case DATE_PICKER_ID:

                    // open datepicker dialog.
                    // set date picker for current date
                    // add pickerListener listner to date picker
                    return new DatePickerDialog(this, pickerListener, year, month,day);
            return null;

    private DatePickerDialog.OnDateSetListener pickerListener;

        pickerListener = new DatePickerDialog.OnDateSetListener() {

            // when dialog box is closed, below method will be called.

            public void onDateSet(int selectedYear,
                                  int selectedMonth, int selectedDay) {

                year = selectedYear;
                month = selectedMonth;
                day = selectedDay;

                // Show selected date
                Output.setText(new StringBuilder().append(month + 1)
                        .append(" "));


            public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {


    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;

    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;

        return super.onOptionsItemSelected(item);