Android DatePicker listener not triggering -


i'm using datepicker widget , can't seem listener trigger, i've put logs everywhere see happening doesn't seem realise date has changed

main.java

datepicker dp = (datepicker) findviewbyid(r.id.datepicker); dp.init(year, month, day, new ondatechangedlistener (){     public void ondatechanged(datepicker dp, int selectedyear, int monthofyear, int dayofmonth)     {         year = selectedyear;         month = monthofyear;         day = dayofmonth;         updatetime(year, month, day);     }; }); // setup initial values , reg. handler 

here section in xml measure

<datepicker      android:id="@+id/datepicker"      android:layout_width="fill_parent"      android:padding="5sp"      android:gravity="center"     android:layout_height="wrap_content"> </datepicker> 

try this

datepicker dp = (datepicker) findviewbyid(r.id.datepicker); dp.init(year, month, day,datepickerlistener); 

and in datepickerlistener add code

private datepicker.ondatechangedlistener datepickerlistener= new ondatechangedlistener (){

@override public void ondateset(datepicker view, int selectedyear, int monthofyear, int dayofmonth){     if (view.isshown()) {         dp.set(selectedyear, monthofyear, dayofmonth);     } } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -