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
Post a Comment