android - Two onCreateDialogs -


im trying use both datepicker , timepicker.i newbie in android. problem 2 oncreatedialogs. eclipce ask me rename second one. when that, timepicker doesnt show up. problem? in advance

// datepicker

    static final int date_dialog_id=0;     int yr,mon,day;     @suppresswarnings("deprecation")     public void showdatepickerdialog(view v)     {          calendar today=calendar.getinstance();          yr=today.get(calendar.year);          mon=today.get(calendar.month);          day=today.get(calendar.day_of_month);         showdialog(date_dialog_id);     }     protected dialog oncreatedialog(int id)     {         switch (id) {         case date_dialog_id:             return new datepickerdialog(this,datesetlistener,yr,mon,day);          }         return null;     }     private datepickerdialog.ondatesetlistener datesetlistener=new datepickerdialog.ondatesetlistener() {          @override         public void ondateset(datepicker view, int year, int monthofyear,                 int dayofmonth) {             // todo auto-generated method stub             yr=year;             mon=monthofyear+1;             day=dayofmonth;             edittext it=(edittext)findviewbyid(r.id.textdate);             it.settext(day+" - "+mon+" - "+yr);         }       };          //timepicker      int hour,min;     static final int time_dialog_id=1;     @suppresswarnings("deprecation")     public void showtimedialog(view v) {         calendar c=calendar.getinstance();         hour=c.get(calendar.hour);         min=c.get(calendar.minute);         showdialog(time_dialog_id);     }     protected dialog oncreatedialog1(int id)     {         switch(id)         {         case time_dialog_id:             return new timepickerdialog(this, timesetlistener, hour, min,true);         }         return null;     }     private timepickerdialog.ontimesetlistener timesetlistener=new timepickerdialog.ontimesetlistener() {          @override         public void ontimeset(timepicker view, int hourofday, int minute) {             // todo auto-generated method stub             hour=hourofday;             min=minute;             edittext et=(edittext)findviewbyid(r.id.texttime);             et.settext(hour+" : "+min);          }       };      // 

combine switch statements in oncreatedialog as:

    case date_dialog_id:         return new datepickerdialog(this,datesetlistener,yr,mon,day);     case time_dialog_id:         return new timepickerdialog(this, timesetlistener, hour, min,true); 

this way appropriate dialog pop depending on input.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -