B4A Library SwitchDateTimePicker

A wrap for this Github project. Extract DemoRes.zip, LibRes.zip, and resource.zip and then copy the folders (with their contents) to be on the same folder level as that of the /Files and /Objects folders of the B4A project. Take note of the B4A manifest file.

You need to enable DesignSupport (V2.00) and AppCompat (V3.20) for the project to work. Copy the attached library files to your additional library folder.

Sample code:
B4X:
#Region  Project Attributes
    #ApplicationLabel: b4aSwitchDateTimePicker
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: portrait
    #CanInstallToExternalStorage: False
#End Region

#AdditionalRes: ..\resource
#AdditionalRes: ..\LibRes
#AdditionalRes: ..\DemoRes


'#AdditionalRes: C:\Android\extras\android\support\v7\appcompat\res, android.support.v7.appcompat
'#AdditionalRes: C:\Android\extras\google\google-play-services\libproject\google-play-services_lib\res, com.google.android.gms
'#AdditionalRes: C:\Android\extras\android\support\design\res, android.support.design

'#ExcludeClasses: .games, .drive, .ads, .fitness, .wearable, .measurement, .cast, .auth, .nearby
'#ExcludeClasses: .tagmanager, .analytics, .wallet, .plus, .gcm, .maps, .panorama

'#Extends: android.support.v7.app.AppCompatActivity

#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
 
End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private Button1 As Button
    Dim sdtp As SwitchDateTimePicker
 
 
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
 
    Activity.LoadLayout("main")
    sdtp.Initialize("sdtp")
 
 
End Sub

Sub Activity_Resume
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Button1_Click

    sdtp.Start_Picker

End Sub

Sub sdtp_selected_date_time(year As Int, month As Int, day As Int, hour As Int, minute As Int, full_date As String)
 
    Log("YEAR = " & year)
    Log("MONTH = " & month)
    Log("DAY = " & day)
    Log("HOUR = " & hour)
    Log("MINUTE = " & minute)
    Log("FULL DATE = " & full_date)
 
End Sub

Sub sdtp_cancelled
 
    Log("CANCELLED")
 
End Sub

Library:
SwitchDateTimePicker
Author:
Github: Jeremy JAMET, Wrapped by: Johan Schoeman
Version: 1
  • SwitchDateTimePicker
    Events:
    • cancelled
    • selected_date_time (year As Int, month As Int, day As Int, hour As Int, minute As Int, full_date As String)
    Methods:
    • Initialize (paramString As String)
    • IsInitialized As Boolean
    • Start_Picker

What it looks like on KitKat:
kitkat1.png



kitkat2.png



What it looks like on Lollipop:
lollipop1.png



lollipop2.png
 

Attachments

  • DemoRes.zip
    31.4 KB · Views: 633
  • LibRes.zip
    18.3 KB · Views: 619
  • resource.zip
    423 bytes · Views: 630
  • SwitchDateTimePickerLibFiles.zip
    15.1 KB · Views: 661
  • b4aSwitchDateTimePicker.zip
    8.5 KB · Views: 644
Last edited:

james_sgp

Active Member
Licensed User
Longtime User
Johan,
Thanks for the help, added that; but no getting a different error:

*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/kunzisoft/switchdatetimesample/Sample;
at switchdatetimepickerwrapper.switchdatetimepickerWrapper.Initialize(switchdatetimepickerWrapper.java:74)
at JHS.SwitchDateTimePicker.main._activity_create(main.java:387)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at JHS.SwitchDateTimePicker.main.afterFirstLayout(main.java:104)
at JHS.SwitchDateTimePicker.main.access$000(main.java:17)
at JHS.SwitchDateTimePicker.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6986)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: java.lang.ClassNotFoundException: com.kunzisoft.switchdatetimesample.Sample
at java.lang.VMClassLoader.findLoadedClass(Native Method)
at java.lang.ClassLoader.findLoadedClass(ClassLoader.java:738)
at java.lang.ClassLoader.loadClass(ClassLoader.java:363)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
 

Johan Schoeman

Expert
Licensed User
Longtime User
What version of B4A are you using? Have you tried to "Jetify" the B4A project and then also do a "Clean Project" before compiling it?
 

Attachments

  • SwitchDateTimePicker.jar
    16.8 KB · Views: 269
  • SwitchDateTimePicker.xml
    1.5 KB · Views: 276
  • SwitchDateTimePicker.androidx.jar
    17.3 KB · Views: 270

james_sgp

Active Member
Licensed User
Longtime User
I`m running, B4A 9.50. Project was already Jetified, copied the files you attached; and it compiles now.

But when I click on the "Show Picker" button in the app, it crashes with the attached error:
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1460)
at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
at androidx.fragment.app.BackStackRecord.executeOps(BackStackRecord.java:802)
at androidx.fragment.app.FragmentManagerImpl.executeOps(FragmentManager.java:2625)
at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2411)
at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2366)
at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
at androidx.fragment.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3273)
at androidx.fragment.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3229)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:201)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:620)
at androidx.appcompat.app.AppCompatActivity.onStart(AppCompatActivity.java:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1391)
at android.app.Activity.performStart(Activity.java:7347)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3116)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6986)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:14
Message longer than Log limit (4000). Message was truncated.
 
Last edited:
Top