Android date picker error -
i develop android app , unfortunately in old devices not working ... set click listener on textview , show datepicker dialogue , in date picker code, setting date same textview .
in activity :
feild_age.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { dialogfragment fragment = new datepickerfragment(); fragment.show(getfragmentmanager(), "date picker"); } });
my code date picker fragment .... code in single activity.
public static class datepickerfragment extends dialogfragment implements datepickerdialog.ondatesetlistener { @requiresapi(api = build.version_codes.n) @override public dialog oncreatedialog(bundle savedinstancestate) { final calendar calendar = calendar.getinstance(); int year = calendar.get(calendar.year); int month = calendar.get(calendar.month); int day = calendar.get(calendar.day_of_month); datepickerdialog dpd = new datepickerdialog(getactivity(), android.app.alertdialog.theme_device_default_dark, this, year, month, day); return dpd; } @requiresapi(api = build.version_codes.n) @override public void ondateset(datepicker datepicker, int year, int month, int day) { // textview textview calendar calendar = calendar.getinstance(); calendar.settimeinmillis(0); calendar.set(year, month, day, 0, 0, 0); date date = calendar.gettime(); dateformat dateformat = dateformat.getdateinstance(dateformat.medium, locale.us); string formateddate = dateformat.format(date); textview feild_age = (textview) getactivity().findviewbyid(r.id.age_of_user); feild_age.settext(formateddate); if (!feild_age.gettext().tostring().trim().equals("select age")) { textview dobb = (textview) getactivity().findviewbyid(r.id.year_ofdob); dobb.settext(string.valueof(year)); } } }
logcat
08-21 22:40:47.015 2755-2755/com.jeffysmak.blooddonationpk e/androidruntime: fatal exception: main process: com.jeffysmak.blooddonationpk, pid: 2755 java.lang.noclassdeffounderror: android.icu.util.calendar @ com.jeffysmak.blooddonationpk.donorprofile$datepickerfragment.oncreatedialog(donorprofile.java:252) @ android.app.dialogfragment.getlayoutinflater(dialogfragment.java:398) @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:890) @ android.app.fragmentmanagerimpl.movetostate(fragmentmanager.java:1062) @ android.app.backstackrecord.run(backstackrecord.java:684) @ android.app.fragmentmanagerimpl.execpendingactions(fragmentmanager.java:1447) @ android.app.fragmentmanagerimpl$1.run(fragmentmanager.java:443) @ android.os.handler.handlecallback(handler.java:733) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:136) @ android.app.activitythread.main(activitythread.java:5045) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:515) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:779) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:595) @ dalvik.system.nativestart.main(native method)
kindly 1 .... :)
java.lang.noclassdeffounderror: android.icu.util.calendar
just changed import android.icu.util.calendar
java.util.calendar
wiki
Comments
Post a Comment