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: 900
  • Ex-Intellvold_DatePicker_V1.7.zip
    317.9 KB · Views: 848
Last edited:

mcqueccu

Well-Known Member
Licensed User
Longtime User
NEW EXAMPLES(Activity and B4XPages). Compatible with B4A 13.10+

Depends on: AppCompat Library

1. Add this to the Main Module

B4X:
#Extends : android.support.v4.app.FragmentActivity
#AdditionalJar: androidx.customview:customview-poolingcontainer

2. Update your manifest

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme) 'Needed for Date Picker

'End of default text.


'Important for the Timepicker
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>

)
 

Attachments

  • B4XPages_Datepicker_Example.zip
    69.4 KB · Views: 100
  • Activity_Example.zip
    63.8 KB · Views: 98

Theera

Expert
Licensed User
Longtime User
NEW EXAMPLES(Activity and B4XPages). Compatible with B4A 13.10+

Depends on: AppCompat Library

1. Add this to the Main Module

B4X:
#Extends : android.support.v4.app.FragmentActivity
#AdditionalJar: androidx.customview:customview-poolingcontainer

2. Update your manifest

Manifest:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="34"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme) 'Needed for Date Picker

'End of default text.


'Important for the Timepicker
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>

)
Your UI is good.I'm like it. Let me do in Thai Edition. Thank you advance.
 

antonomase

Active Member
Licensed User
Longtime User
Note to @intellvold: perhaps it would be a good idea to include all the information about adding an AdditionalJar and modifying the Manifest in the first post.
 
Last edited:
Top