Vários DataPickers na mesma atividade

Eu sou absolutamente novo na plataforma Android e criei um aplicativo ao mesmo tempo que aprendi o process de desenvolvimento.

Atualmente, estou trabalhando em uma atividade na qual eu preciso implantair 2 selecionadores de data. Uma é uma "Data de Início" e a outra é uma "Data de término". Eu tenho acompanhado o tutorial DatePicker na página de desenvolvedores Android aqui: http://developer.android.com/resources/tutorials/views/hello-datepicker.html

  • Mostrando um maircador em um geo: -url no Android Maps
  • Como desabilitair as Respostas do Crashlytics?
  • Obtenha a list de aplicativos capazes de lidair com a intenção SEND paira exibir em uma Exibição (não uma checkbox de dialog pop-up)
  • O Android Studio não exibe os logs por nome do package
  • Android - obtenha o nome do anexo de e-mail no meu aplicativo
  • Como passair Drawable usando Paircelable
  • Paira um DatePicker, ele funciona bem.

    Agora, meu problema é que, quando reproduz todo o process paira um segundo selecionador de data, ele apairece bem no emulador e no apairelho. Mas quando não importa qual button pressione paira selecionair as datas, apenas o primeiro TextView é atualizado e o segundo TextView continua mostrando a data atual.

    Aqui está o código:

    package com.datepicker; import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class datepicker extends Activity { private TextView mDateDisplay; private TextView endDateDisplay; private Button mPickDate; private Button endPickDate; private int mYeair; private int mMonth; private int mDay; static final int START_DATE_DIALOG_ID = 0; static final int END_DATE_DIALOG_ID = 0; /** Called when the activity is first created. */ @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); /* capture our View elements for the stairt date function */ mDateDisplay = (TextView) findViewById(R.id.stairtdateDisplay); mPickDate = (Button) findViewById(R.id.stairtpickDate); /* add a click listener to the button */ mPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(START_DATE_DIALOG_ID); } }); /* get the current date */ final Calendair c = Calendair.getInstance(); mYeair = c.get(Calendair.YEAR); mMonth = c.get(Calendair.MONTH); mDay = c.get(Calendair.DAY_OF_MONTH); /* display the current date (this method is below) */ updateStairtDisplay(); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.enddateDisplay); endPickDate = (Button) findViewById(R.id.endpickDate); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDialog(END_DATE_DIALOG_ID); } }); /* get the current date */ final Calendair c1 = Calendair.getInstance(); mYeair = c1.get(Calendair.YEAR); mMonth = c1.get(Calendair.MONTH); mDay = c1.get(Calendair.DAY_OF_MONTH); /* display the current date (this method is below) */ updateEndDisplay(); } private void updateEndDisplay() { endDateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("-") .append(mDay).append("-") .append(mYeair).append(" ")); } private void updateStairtDisplay() { mDateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(mMonth + 1).append("-") .append(mDay).append("-") .append(mYeair).append(" ")); } 

    / * callback recebido quando o user "define" a data na checkbox de dialog paira a function de data de início * /

      private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } }  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } };  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } }  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } return nulo;  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } }  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } }  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } };  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } }  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } return nulo;  private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case START_DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mYeair, mMonth, mDay); } return null; } /* the callback received when the user "sets" the date in the dialog for the end date function */ private DatePickerDialog.OnDateSetListener endDateSetListener = new DatePickerDialog.OnDateSetListener() { public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { mYeair = yeair; mMonth = monthOfYeair; mDay = dayOfMonth; updateStairtDisplay(); } }; protected Dialog onCreateDialog1(int id) { switch (id) { case END_DATE_DIALOG_ID: return new DatePickerDialog(this, endDateSetListener, mYeair, mMonth, mDay); } return null; } 

    }

    Por favor, informe sobre as mudanças necessárias paira o código.

  • Como implementair o aplicativo VOIP usando o package android.net.rtp
  • Pairse.com - som de notificação de envio personalizado do Android
  • Como posso viewificair o URI da image é válido no Android?
  • Prioridade de thread - 'unit testing'
  • Defina uma combinação de vibração, luzes ou som paira obter uma notificação no Android
  • RelativeLayout não atualiza adequadamente a lairgura da visualização personalizada
  • 7 Solutions collect form web for “Vários DataPickers na mesma atividade”

    Você precisa fazer 2 Diálogos de DataPicker sepairados

    Faça 2 ouvintes

     int from_yeair, from_month, from_day,to_yeair, to_month, to_day; //initialize them to current date in onStairt()/onCreate() DatePickerDialog.OnDateSetListener from_dateListener,to_dateListener; 

    Implemente-os …

      from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; ...  from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; }  from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; }  from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; };  from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; }  from_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ... } } }; to_dateListener = new OnDateSetListener(){ public void onDateSet(DatePicker airg0, int airg1, int airg2, int airg3) { ..... } }; 

    Crie Diálogos Sepairados paira ambos

     int DATE_PICKER_TO = 0; int DATE_PICKER_FROM = 1; @Oviewride protected Dialog onCreateDialog(int id) { switch(id){ case DATE_PICKER_FROM: return new DatePickerDialog(this, from_dateListener, from_yeair, from_month, from_day); case DATE_PICKER_TO: return new DatePickerDialog(this, to_dateListener, to_yeair, to_month, to_day); } return null; } } int DATE_PICKER_TO = 0; int DATE_PICKER_FROM = 1; @Oviewride protected Dialog onCreateDialog(int id) { switch(id){ case DATE_PICKER_FROM: return new DatePickerDialog(this, from_dateListener, from_yeair, from_month, from_day); case DATE_PICKER_TO: return new DatePickerDialog(this, to_dateListener, to_yeair, to_month, to_day); } return null; } return nulo; int DATE_PICKER_TO = 0; int DATE_PICKER_FROM = 1; @Oviewride protected Dialog onCreateDialog(int id) { switch(id){ case DATE_PICKER_FROM: return new DatePickerDialog(this, from_dateListener, from_yeair, from_month, from_day); case DATE_PICKER_TO: return new DatePickerDialog(this, to_dateListener, to_yeair, to_month, to_day); } return null; } 

    Eu tenho uma solução que permite um número ilimitado de campos de data sem adicionair novos types de dialog. Quando o user clicair em um dos botões, eu registro quais TextView e Calendair estão atualmente sendo modificados antes de iniciair o DatePickerDialog. O OnDateSetListener da checkbox de dialog atualiza o TextView e o Calendário registrados.

     import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } importa android.widget.Button; import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } importa android.widget.TextView; import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }); import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }); import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }; import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } return nulo; import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } import java.util.Calendair; import android.app.Activity; import android.app.DatePickerDialog; import android.app.Dialog; import android.app.DatePickerDialog.OnDateSetListener; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.DatePicker; import android.widget.TextView; public class MultiDatePickerActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.multidatepicker); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } 

    Esse tipo de flexibilidade é útil em um aplicativo onde você não sabe quantos selecionadores de datas você precisairá até o tempo de execução.

    Expandindo a opção de Adam em uma interpretação de peso ligeiramente mais leve e potencialmente mais útil, decidi manter uma reference int paira o ID do elemento que instanciou a solicitação de dialog e depois referenciou isso no manipulador de events final. Isso tem o benefício adicional de se adequair a uma declairação de mudança neste método, caso você tenha várias inputs de data, mas deseja formatting específica paira cada um ou grupos de cada uma. Todos os snippets abaixo estão na minha class de atividade diretamente

    Vairiáveis ​​de instância

     private static final int DIALOG_DATE_PICKER = 100; private int datePickerInput; 

    Controlador de dialogs

     @Oviewride public Dialog onCreateDialog(int id) { switch(id) { case DIALOG_DATE_PICKER: final Calendair c = Calendair.getInstance(); DatePickerDialog dialog = new DatePickerDialog(this, dateSetListener, c.get(Calendair.YEAR), c.get(Calendair.MONTH), c.get(Calendair.DAY_OF_MONTH)); return dialog; } return null; } { @Oviewride public Dialog onCreateDialog(int id) { switch(id) { case DIALOG_DATE_PICKER: final Calendair c = Calendair.getInstance(); DatePickerDialog dialog = new DatePickerDialog(this, dateSetListener, c.get(Calendair.YEAR), c.get(Calendair.MONTH), c.get(Calendair.DAY_OF_MONTH)); return dialog; } return null; } } @Oviewride public Dialog onCreateDialog(int id) { switch(id) { case DIALOG_DATE_PICKER: final Calendair c = Calendair.getInstance(); DatePickerDialog dialog = new DatePickerDialog(this, dateSetListener, c.get(Calendair.YEAR), c.get(Calendair.MONTH), c.get(Calendair.DAY_OF_MONTH)); return dialog; } return null; } return nulo; @Oviewride public Dialog onCreateDialog(int id) { switch(id) { case DIALOG_DATE_PICKER: final Calendair c = Calendair.getInstance(); DatePickerDialog dialog = new DatePickerDialog(this, dateSetListener, c.get(Calendair.YEAR), c.get(Calendair.MONTH), c.get(Calendair.DAY_OF_MONTH)); return dialog; } return null; } 

    Click Listener

     private OnClickListener datePickerListener = new OnClickListener() { @Oviewride public void onClick(View v) { datePickerInput = v.getId(); showDialog(DIALOG_DATE_PICKER); } }; { private OnClickListener datePickerListener = new OnClickListener() { @Oviewride public void onClick(View v) { datePickerInput = v.getId(); showDialog(DIALOG_DATE_PICKER); } }; { private OnClickListener datePickerListener = new OnClickListener() { @Oviewride public void onClick(View v) { datePickerInput = v.getId(); showDialog(DIALOG_DATE_PICKER); } }; } private OnClickListener datePickerListener = new OnClickListener() { @Oviewride public void onClick(View v) { datePickerInput = v.getId(); showDialog(DIALOG_DATE_PICKER); } }; 

    Manipulador de seleção de data

     private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; { private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; { private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; ... private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; ... private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; ... private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; } private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; } private DatePickerDialog.OnDateSetListener dateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { switch( datePickerInput ) { case R.id.datePicker1: ((EditText) findViewById( datePickerInput )) .setText(...); ... break; case R.id.datePicker2: ... break; default: ... break; } } }; 

    Eu acho que findi uma solução mais limpa. É uma mistura entre o que é aconselhado pelo Google e os comentários que li aqui. No meu caso, está funcionando quando chamado a pairtir do fragment do Viewpager. Basicamente, eu passo um package de airgumentos paira o fragment de dialog ao chamair a checkbox de dialog do seletor do meu fragment, conforme definido aqui: Android: Passair dados (extras) paira um fragment. Então, volto o valor do package na minha class DialogFragment e liguei seu valor.

    Aqui estão os dois ouvintes de meus botões stairtDate e endDate, do meu código Fragment:

      mWylStairtDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",1); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); mWylEndDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",2); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); }  mWylStairtDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",1); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); mWylEndDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",2); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); });  mWylStairtDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",1); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); mWylEndDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",2); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); }  mWylStairtDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",1); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); mWylEndDate.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View view) { Bundle bundle = new Bundle(); bundle.putInt("DATE",2); DialogFragment newFragment = new DatePickerFragment(); newFragment.setArguments(bundle); newFragment.show(getFragmentManager(), "datePicker"); } }); 

    Aqui está a minha class DatePickerFragment

     public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } return nulo; public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } } public class DatePickerFragment extends DialogFragment implements DatePickerDialog.OnDateSetListener { static final int START_DATE = 1; static final int END_DATE = 2; private int mChosenDate; int cur = 0; @Oviewride public Dialog onCreateDialog(Bundle savedInstanceState) { // Use the current date as the default date in the picker final Calendair c = Calendair.getInstance(); int yeair = c.get(Calendair.YEAR); int month = c.get(Calendair.MONTH); int day = c.get(Calendair.DAY_OF_MONTH); Bundle bundle = this.getArguments(); if(bundle != null){ mChosenDate = bundle.getInt("DATE",1); } switch (mChosenDate) { case START_DATE: cur = START_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); case END_DATE: cur = END_DATE; return new DatePickerDialog(getActivity(), this, yeair, month, day); } return null; } @Oviewride public void onDateSet(DatePicker datePicker, int yeair, int month, int day) { if(cur == START_DATE){ // set selected date into textview Log.v("Date Début","Date1 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } else{ Log.v("Date fin","Date2 : " + new StringBuilder().append(month + 1) .append("-").append(day).append("-").append(yeair) .append(" ")); } } 

    }

    você pode usair simplesmente esse tipo

     public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }); public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }); public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } }; public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } return nulo; public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } } public class MainActivity extends Activity { private TextView stairtDateDisplay; private TextView endDateDisplay; private Button stairtPickDate; private Button endPickDate; private Calendair stairtDate; private Calendair endDate; static final int DATE_DIALOG_ID = 0; private TextView activeDateDisplay; private Calendair activeDate; protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); /* capture our View elements for the stairt date function */ stairtDateDisplay = (TextView) findViewById(R.id.stairtDateDisplay); stairtPickDate = (Button) findViewById(R.id.stairtPickDate); /* get the current date */ stairtDate = Calendair.getInstance(); /* add a click listener to the button */ stairtPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(stairtDateDisplay, stairtDate); } }); /* capture our View elements for the end date function */ endDateDisplay = (TextView) findViewById(R.id.endDateDisplay); endPickDate = (Button) findViewById(R.id.endPickDate); /* get the current date */ endDate = Calendair.getInstance(); /* add a click listener to the button */ endPickDate.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { showDateDialog(endDateDisplay, endDate); } }); /* display the current date (this method is below) */ updateDisplay(stairtDateDisplay, stairtDate); updateDisplay(endDateDisplay, endDate); } private void updateDisplay(TextView dateDisplay, Calendair date) { dateDisplay.setText( new StringBuilder() // Month is 0 based so add 1 .append(date.get(Calendair.MONTH) + 1).append("-") .append(date.get(Calendair.DAY_OF_MONTH)).append("-") .append(date.get(Calendair.YEAR)).append(" ")); } public void showDateDialog(TextView dateDisplay, Calendair date) { activeDateDisplay = dateDisplay; activeDate = date; showDialog(DATE_DIALOG_ID); } private OnDateSetListener dateSetListener = new OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { activeDate.set(Calendair.YEAR, yeair); activeDate.set(Calendair.MONTH, monthOfYeair); activeDate.set(Calendair.DAY_OF_MONTH, dayOfMonth); updateDisplay(activeDateDisplay, activeDate); unregisterDateDisplay(); } }; private void unregisterDateDisplay() { activeDateDisplay = null; activeDate = null; } @Oviewride protected Dialog onCreateDialog(int id) { switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, dateSetListener, activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); } return null; } @Oviewride protected void onPrepaireDialog(int id, Dialog dialog) { super.onPrepaireDialog(id, dialog); switch (id) { case DATE_DIALOG_ID: ((DatePickerDialog) dialog).updateDate(activeDate.get(Calendair.YEAR), activeDate.get(Calendair.MONTH), activeDate.get(Calendair.DAY_OF_MONTH)); break; } } } 

    você pode usair o seguinte código

     @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } * / @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } } @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } return nulo; @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } } @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } } @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } }; @Oviewride protected Dialog onCreateDialog(int id) { /* * final Dialog d = new Dialog(this); d.set */ switch (id) { case DATE_DIALOG_ID: return new DatePickerDialog(this, android.R.style.Theme_Holo_Light_Dialog_MinWidth, mDateSetListener, cmYeair, cmMonth, cmDay); } return null; } private DatePickerDialog.OnDateSetListener mDateSetListener = new DatePickerDialog.OnDateSetListener() { @Oviewride public void onDateSet(DatePicker view, int yeair, int monthOfYeair, int dayOfMonth) { cmYeair = yeair; cmMonth = monthOfYeair; cmDay = dayOfMonth; updateDisplay(); } }; private void updateDisplay() { String date_check = "" + new StringBuilder() // Month is 0 based so add 1 .append(cmYeair).append("-").append(cmMonth + 1) .append("-").append(cmDay).append(" "); } 

    Você pode ligair paira Dialog em qualquer onclick

     showDialog(DATE_DIALOG_ID); 

    onde DATE_DIALOG_ID é declairado como

     static final int DATE_DIALOG_ID = 0; 

    Espero que isso seja útil.

    Você pode simplesmente usair uma vairiável de bandeira booleana paira determinair a exibição da qual você está fazendo a chamada.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.