B4A Library Material Date Picker

Material Date - Time Picker Dialog

Updated :)


This Library wrape for this github

work on B4a v11

SetMinDate
SetMaxDate
CancelColor
CancelText
OkColor
OkText
Title
DarkMode
On Cancel
OnDateset
2 layout Mode
Added Dismiss_Dialog


Events :

_OnCancelDate()
_OnDateSet()
_OnCancelTime ()
_OnTimeSet()



Added this line in activity:
B4X:
#Extends : android.support.v4.app.FragmentActivity


Example code:
Sub Globals
   Dim Datepicker As Intellvold_DatePicker
   Dim Mycalendar As Intellvold_Calendar
   Dim Timepicker As Intellvold_TimePicker
End Sub


Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub

Sub Button1_Click
    Datepicker.Initialize("Date",2022 ,DateTime.GetMonth(DateTime.Now) ,DateTime.GetDayOfMonth(DateTime.Now))
    Mycalendar.Initialize("dd.mm.yyyy",Mycalendar.PRC,"2.02.1990") 'start date
'   Datepicker.SetThemeDark
    Datepicker.SetMinDate(Mycalendar)
    Mycalendar.Initialize("dd.mm.yyyy",Mycalendar.PRC,"2.02.2030") 'end date
    Datepicker.SetMaxDate(Mycalendar)
    Datepicker.CancelColor = Colors.Red
    Datepicker.OkColor = Colors.Green
    Datepicker.Title = "IntellVold"
    Datepicker.CancelText = "yox"
    Datepicker.OkText = "bəli"
'   Datepicker.SetThemeDark
    Datepicker.SetOnCancel("can")
'   Datepicker.show("bir")
    Datepicker.show2("iki")
    Datepicker.About
    Sleep(10000)
'   Datepicker.Dismiss_Dialog
End Sub


Sub Date_OnDateSet (year As Int ,monthOfYear As Int , dayOfMonth As Int)
    ToastMessageShow(year&"/"&(NumberFormat(monthOfYear,2 ,0))&"/"&NumberFormat(dayOfMonth ,2 ,0) ,False)
    Msgbox(year&"/"&(NumberFormat(monthOfYear,2 ,0))&"/"&NumberFormat(dayOfMonth ,2 ,0) ,"")
End Sub

Sub can_OnCancelDate ()
    ToastMessageShow("cancel" ,False)
End Sub

Private Sub Button2_Click
    Timepicker.Initialize("Time" ,21 ,45 ,True)
    Timepicker.CancelColor = Colors.Red
    Timepicker.CancelText = "yox"
    Timepicker.OkColor = Colors.Yellow
    Timepicker.OkText = "bəli"
    Timepicker.SetOnCancel("Time")
'   Timepicker.SetThemeDark
    Timepicker.show("bir")
    Timepicker.Title = "TimeIntellvold"
    Sleep(4000)
'   Timepicker.Dismiss_Dialog
End Sub

Sub Time_OnCancelTime ()
    Log("Time_OnCancelTime")
End Sub

Sub Time_OnTimeSet (hourOfDay As Int ,minute As Int , second As Int)
    ToastMessageShow(hourOfDay&":"&minute&":"&second ,False)
    Msgbox(hourOfDay&":"&minute&":"&second ,"")
End Sub



Set custom theme color—> colorAccent in manifest for change time picker color.

custom color :
SetApplicationAttribute(android:theme, "@style/MyAppTheme")
CreateResource(values, theme.xml,
<resources>
    <style name="MyAppTheme" parent="Theme.AppCompat.Light.NoActionBar">
 
 
 
 
 <item name="colorAccent">#040925</item>
        <item name="windowNoTitle">true</item>
        <item name="windowActionBar">false</item>
        <item name="android:navigationBarColor">#FF000000</item>
 
 
 
    </style>
</resources>
)


Screenshot_1665352162.png
Screenshot_1665352168.png





date2.gif
time2.gif
 

Attachments

  • Intellvold_DatePickerV1.7.zip
    313 KB · Views: 626
  • Ex-Intellvold_DatePicker_V1.7.zip
    317.9 KB · Views: 595
Last edited:

Lello1964

Well-Known Member
Licensed User
Longtime User
I'm trying to compile your sample using b4a v. 12, i've this error :

error compiling:
B4A Versione: 12.00
Analisi del Codice.    (0.01s)
    Java Versione: 11
Building folders structure.    (0.71s)
Compilazione del codice.    (0.03s)
Compilazione del codice di layouts    (0.00s)
Organizzazione Librerie.    (0.06s)
    (AndroidX SDK)
Compilazione risorse    (6.45s)
Collegamento risorse    (1.91s)
Compilazione del codice debugger.    (1.21s)
Compilazione del codice Java prodotto.    (5.17s)
Ricerca librerie che necessitano di essere "dexed".    (0.03s)
Dex code    (3.42s)
Dex merge    Error
Error: Cannot fit requested classes in a single dex file (# fields: 72853 > 65536). Try supplying a main-dex list
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:98)
    at com.android.tools.r8.D8.main(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
    at Version.fakeStackEntry(Version_3.3.20-dev+aosp1.java:0)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:75)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:27)
    at com.android.tools.r8.internal.vj.b(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:2)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:17)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:85)
    ... 1 more
Caused by: com.android.tools.r8.internal.f: Cannot fit requested classes in a single dex file (# fields: 72853 > 65536)
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:14)
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.internal.v20.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:565)
    at com.android.tools.r8.internal.r20.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:7)
    at com.android.tools.r8.internal.D2.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:335)
    at com.android.tools.r8.internal.D2.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:412)
    at com.android.tools.r8.D8.d(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:794)
    at com.android.tools.r8.D8.c(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:1)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:24)
    ... 5 more
 

Xfood

Expert
Licensed User
I'm trying to compile your sample using b4a v. 12, i've this error :

error compiling:
B4A Versione: 12.00
Analisi del Codice.    (0.01s)
    Java Versione: 11
Building folders structure.    (0.71s)
Compilazione del codice.    (0.03s)
Compilazione del codice di layouts    (0.00s)
Organizzazione Librerie.    (0.06s)
    (AndroidX SDK)
Compilazione risorse    (6.45s)
Collegamento risorse    (1.91s)
Compilazione del codice debugger.    (1.21s)
Compilazione del codice Java prodotto.    (5.17s)
Ricerca librerie che necessitano di essere "dexed".    (0.03s)
Dex code    (3.42s)
Dex merge    Error
Error: Cannot fit requested classes in a single dex file (# fields: 72853 > 65536). Try supplying a main-dex list
Compilation failed
Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:98)
    at com.android.tools.r8.D8.main(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:4)
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, position: null
    at Version.fakeStackEntry(Version_3.3.20-dev+aosp1.java:0)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:75)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:28)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:27)
    at com.android.tools.r8.internal.vj.b(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:2)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.D8.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:17)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:85)
    ... 1 more
Caused by: com.android.tools.r8.internal.f: Cannot fit requested classes in a single dex file (# fields: 72853 > 65536)
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:14)
    at com.android.tools.r8.internal.YS.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:22)
    at com.android.tools.r8.internal.v20.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:565)
    at com.android.tools.r8.internal.r20.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:7)
    at com.android.tools.r8.internal.D2.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:335)
    at com.android.tools.r8.internal.D2.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:412)
    at com.android.tools.r8.D8.d(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:794)
    at com.android.tools.r8.D8.c(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:1)
    at com.android.tools.r8.internal.vj.a(R8_3.3.20-dev+aosp1_dd4c01853fd917497aef2d09abff533f0d25b062517ea74449d40e1778a34753:24)
    ... 5 more
try putting
'main module
#MultiDex: True
 

Lello1964

Well-Known Member
Licensed User
Longtime User
but my app have this erorr :

B4X:
Error occurred on line: 2810 (MainPage)
java.lang.ClassCastException: cloud.pagamico.cassa.mainpage cannot be cast to androidx.fragment.app.FragmentActivity
    at lib.intellvold.datepicker.DatePicker.show2(DatePicker.java:106)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:197)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:7171)
    at android.view.View.performClickInternal(View.java:7148)
    at android.view.View.access$3500(View.java:802)
    at android.view.View$PerformClick.run(View.java:27409)
    at android.os.Handler.handleCallback(Handler.java:883)
    at android.os.Handler.dispatchMessage(Handler.java:100)
    at android.os.Looper.loop(Looper.java:214)
    at android.app.ActivityThread.main(ActivityThread.java:7626)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:503)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
 

Theera

Well-Known Member
Licensed User
Longtime User
How to use other countries in the line code and change Budhism year?
Please guide for me. I'm not good at English and programming,but I have tried to learn B4A.
Mycalendar.Initialize("dd.mm.yyyy",Mycalendar.PRC,"2.02.1990") 'start date
 

intellvold

Member
Licensed User
How to use other countries in the line code and change Budhism year?
Please guide for me. I'm not good at English and programming,but I have tried to learn B4A.
Regarding the time, each region is different, but regarding the date, only the Gregorian date may be set in this library by taking the current Gregorian date of the device.

Again, if you want about different calendars in different types, you can check the github link of this library and if it is available, it will be updated.:)
 
Top