dialog - Android Calendar View for Date Picker with api level above 11 -


i wanted write application has button , when click on button want display calender in dialog box datepicker in dialog box.

i try constructor likes new datepickerdialog.ondatesetlistener() calender. not possible this?

after api level 11 supports calender view.

//this code shows calendar in dialog, hope helps

layoutinflater inflater =(layoutinflater)getapplicationcontext().getsystemservice(context.layout_inflater_service);     linearlayout ll = (linearlayout)inflater.inflate(r.layout.calendar, null,  false);     calendarview cv = (calendarview) ll.findviewbyid(r.id.calendarview);     cv.setbackgroundcolor(color.black);       cv.setondatechangelistener(new calendarview.ondatechangelistener() {      @override     public void onselecteddaychange(calendarview view, int year, int month,             int dayofmonth) {         // todo auto-generated method stub          log.d("date selected", "date selected " + year + " " + month + " " + dayofmonth);         int rows = showmapfragment(year, month, dayofmonth);          if (rows == 0){             toast.maketext(getapplicationcontext(), year + "/" + (month + 1) +"/" + dayofmonth + " no route display", toast.length_short).show();         }          }     });      ll.findviewbyid(r.id.calendarview).setonclicklistener(new view.onclicklistener() {          @override         public void onclick(view v) {             log.d("calendar view", "calendar view clicked");         }     });      dialog calendardialog = new dialog(main.this);     calendardialog.setcontentview(ll);         calendardialog.settitle("pick date view performance , route");     calendardialog.show();     

//the following calendar layout xml file

<linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/mylayout" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <calendarview android:id="@+id/calendarview" android:layout_width="match_parent" android:layout_height= "400dp" android:showweeknumber="false" android:clickable="true" android:weekdaytextappearance="@style/calendarstyle" android:datetextappearance="@style/calendarstyle"  />  </linearlayout> 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -