android - Datepicker not showing when clicked the first time -
i have editfield , when click on datepicker open not able datepicker popup when clicked first time. if click editfield first time, datepicker not appear. when click second or third time, showing. here code:
public class mainactivity extends activity implements onclicklistener { private calendar calendar; private int day; private int month; private int year; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity); date = (edittext) findviewbyid(r.id.date); calendar = calendar.getinstance(); day = calendar.get(calendar.day_of_month); month = calendar.get(calendar.month); year = calendar.get(calendar.year); date.setonclicklistener(this); } @override protected dialog oncreatedialog(int id) { // todo auto-generated method stub return new datepickerdialog(this, datepickerlistener, year, month, day); } private datepickerdialog.ondatesetlistener datepickerlistener = new datepickerdialog.ondatesetlistener() { public void ondateset(datepicker view, int selectedyear, int selectedmonth, int selectedday) { date.settext(selectedyear + " - " + (selectedmonth + 1) + " - " + selectedday); } }; @override public void onclick(view v) { // todo auto-generated method stub showdialog(0); } }
in layout xml, in edittext-
android:focusableintouchmode="false"
this work
Comments
Post a Comment