android - datepicker in child activity of activitygroup raises BadTokenException error -


i need display 2 datepickers in child activity of activitygroup in tabbed activity. code 2 textviews , buttons display date is:

  incorp_date=(textview)findviewbyid(r.id.edt_incorpdate);     incorp_date_image=(button)findviewbyid(r.id.incorp_date);       incorp_date_cal=calendar.getinstance();      incorp_date_image.setonclicklistener(new view.onclicklistener() {          public void onclick(view v) {             showdialog(date_picker_incorp);         }     });      final calendar c = calendar.getinstance();     incorp_year = c.get(calendar.year);     incorp_month = c.get(calendar.month);     incorp_day = c.get(calendar.day_of_month);      /* display current date (this method below)  */     updateincorpdisplay();       estb_date=(textview)findviewbyid(r.id.edt_estabdate);     estb_date_image=(button)findviewbyid(r.id.estb_date);     estb_date_cal=calendar.getinstance();      estb_date_image.setonclicklistener(new view.onclicklistener() {          public void onclick(view v) {             showdialog(date_picker_estb);         }     });     final calendar c1 = calendar.getinstance();     estb_year = c1.get(calendar.year);     estb_month = c1.get(calendar.month);     estb_day = c1.get(calendar.day_of_month);      /* display current date (this method below)  */     updateestbdisplay(); 

the code display datepicker dialog is:

incorp_datelistener=new ondatesetlistener() {          @override         public void ondateset(datepicker view, int year, int monthofyear,                 int dayofmonth) {             // todo auto-generated method stub             incorp_year = year;             incorp_month = monthofyear;             incorp_day = dayofmonth;             updateincorpdisplay();         }     };      estb_datelistener=new ondatesetlistener() {          @override         public void ondateset(datepicker view, int year, int monthofyear,                 int dayofmonth) {             // todo auto-generated method stub             estb_year = year;             estb_month = monthofyear;             estb_day = dayofmonth;             updateestbdisplay();         }     };   @override protected dialog oncreatedialog(int id) {      switch(id){         case date_picker_incorp:                 return new datepickerdialog(getparent(), incorp_datelistener, incorp_year, incorp_month, incorp_day);              case date_picker_estb:                 return new datepickerdialog(getparent(), estb_datelistener, estb_year, estb_month, estb_day);     }         return null; } 

i not able display datepicker dialog. application force closes when click button , exception of badtokenexception raised.. should do??? cant seem figure out problem is??? think maybe because child activity of activitygroup.. cant find relevant solution.. please help!!!!

try this,first create tabcontext object in tabactivity class.like this

package com.loanreminder;  import android.app.tabactivity; import android.os.bundle;  /**  * @author adil soomro  *   */ public class tabsample extends tabactivity {     /** called when activity first created. */     public static tabsample tabcontext;      public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.tabhost);         tabcontext = this;      }  } 

after use object in activity.

protected dialog oncreatedialog(int id) {      switch(id){         case date_picker_incorp:                 return new datepickerdialog(tabsample.tabcontext, incorp_datelistener, incorp_year, incorp_month, incorp_day);              case date_picker_estb:                 return new datepickerdialog(tabsample.tabcontext, estb_datelistener, estb_year, estb_month, estb_day);     }         return null; } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -