Mar 21, 2013 Replies: 244 This is an old version. Latest version is included in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content AnotherDatePicker is an inline date picker: The advantage of this class over the built-in dialog (DateDialog from the Dialogs library) is that you can easily customize it as needed. Most of the layout is created with the visual designer and designer script. ADP.GetDate returns the selected date. The months names and days names are based on the device locale. In order to use this class in your code you should add AnotherDatePicker class, reference DateUtils library and add DatePicker layout file to the Files tab. Starting from v2.0, ADP should be added as a custom view from the designer: v2.0 - Better support for visual designer and more configurable options (including first day of week). v1.11 - Fixes an issue with SetDate that is called before the view is ready. v1.10 - Adds a Closed event. See the attached example. Attachments AnotherDatePicker.zip AnotherDatePicker.zip 13.2 KB · Views: 4,468 Last edited: Feb 18, 2019 Click to expand...
This is an old version. Latest version is included in XUI Views: https://www.b4x.com/android/forum/threads/100836/#content AnotherDatePicker is an inline date picker: The advantage of this class over the built-in dialog (DateDialog from the Dialogs library) is that you can easily customize it as needed. Most of the layout is created with the visual designer and designer script. ADP.GetDate returns the selected date. The months names and days names are based on the device locale. In order to use this class in your code you should add AnotherDatePicker class, reference DateUtils library and add DatePicker layout file to the Files tab. Starting from v2.0, ADP should be added as a custom view from the designer: v2.0 - Better support for visual designer and more configurable options (including first day of week). v1.11 - Fixes an issue with SetDate that is called before the view is ready. v1.10 - Adds a Closed event. See the attached example.
NeoTechni Well-Known Member Licensed User Longtime User Aug 31, 2013 #41 I'm getting java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:17) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123) at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:190) at b4a.example.main._activity_create(main.java:235) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at b4a.example.main.afterFirstLayout(main.java:89) at b4a.example.main.access$100(main.java:16) at b4a.example.main$WaitForLayout.run(main.java:74) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: anywheresoftware/b4a/objects/CustomViewWrapper ... 24 more Caused by: java.lang.ClassNotFoundException: Didn't find class "anywheresoftware.b4a.objects.CustomViewWrapper" on path: DexPathList[[zip file "/data/app/b4a.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-2, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 24 more main_activity_create (java line: 235) java.lang.RuntimeException: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:140) at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:190) at b4a.example.main._activity_create(main.java:235) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at b4a.example.main.afterFirstLayout(main.java:89) at b4a.example.main.access$100(main.java:16) at b4a.example.main$WaitForLayout.run(main.java:74) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:240) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123) ... 17 more Caused by: java.lang.NoClassDefFoundError: anywheresoftware/b4a/objects/CustomViewWrapper ... 23 more Caused by: java.lang.ClassNotFoundException: Didn't find class "anywheresoftware.b4a.objects.CustomViewWrapper" on path: DexPathList[[zip file "/data/app/b4a.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-2, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 23 more java.lang.RuntimeException: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper
I'm getting java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:17) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:233) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123) at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:190) at b4a.example.main._activity_create(main.java:235) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at b4a.example.main.afterFirstLayout(main.java:89) at b4a.example.main.access$100(main.java:16) at b4a.example.main$WaitForLayout.run(main.java:74) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.NoClassDefFoundError: anywheresoftware/b4a/objects/CustomViewWrapper ... 24 more Caused by: java.lang.ClassNotFoundException: Didn't find class "anywheresoftware.b4a.objects.CustomViewWrapper" on path: DexPathList[[zip file "/data/app/b4a.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-2, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 24 more main_activity_create (java line: 235) java.lang.RuntimeException: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:140) at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:190) at b4a.example.main._activity_create(main.java:235) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at anywheresoftware.b4a.BA.raiseEvent2(BA.java:167) at b4a.example.main.afterFirstLayout(main.java:89) at b4a.example.main.access$100(main.java:16) at b4a.example.main$WaitForLayout.run(main.java:74) at android.os.Handler.handleCallback(Handler.java:730) at android.os.Handler.dispatchMessage(Handler.java:92) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:5103) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:525) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper at java.lang.Class.classForName(Native Method) at java.lang.Class.forName(Class.java:204) at java.lang.Class.forName(Class.java:169) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:240) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:273) at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:123) ... 17 more Caused by: java.lang.NoClassDefFoundError: anywheresoftware/b4a/objects/CustomViewWrapper ... 23 more Caused by: java.lang.ClassNotFoundException: Didn't find class "anywheresoftware.b4a.objects.CustomViewWrapper" on path: DexPathList[[zip file "/data/app/b4a.example-2.apk"],nativeLibraryDirectories=[/data/app-lib/b4a.example-2, /vendor/lib, /system/lib]] at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53) at java.lang.ClassLoader.loadClass(ClassLoader.java:501) at java.lang.ClassLoader.loadClass(ClassLoader.java:461) ... 23 more java.lang.RuntimeException: java.lang.ClassNotFoundException: anywheresoftware.b4a.objects.CustomViewWrapper
Erel B4X founder Staff member Licensed User Longtime User Sep 1, 2013 #42 Which version of Basic4android are you using?
Erel B4X founder Staff member Licensed User Longtime User Sep 1, 2013 #44 This class requires v2.7 as it is a custom view with designer support (a feature added in v2.7).
yttrium Active Member Licensed User Longtime User Oct 16, 2013 #45 Hey Erel, any idea on how to disable dates past the current date? For example, if today is the 16th of October, I don't want users to be able to select any dates past the 16th.
Hey Erel, any idea on how to disable dates past the current date? For example, if today is the 16th of October, I don't want users to be able to select any dates past the 16th.
Erel B4X founder Staff member Licensed User Longtime User Oct 16, 2013 #46 The simplest solution is to check the chosen date and if it is in the future you show a message and ask to choose again. You can also go over the code, understand it, and change it so it will not show future dates.
The simplest solution is to check the chosen date and if it is in the future you show a message and ask to choose again. You can also go over the code, understand it, and change it so it will not show future dates.
yttrium Active Member Licensed User Longtime User Oct 16, 2013 #47 For the first case, how could I determine that? DateUtils.PeriodBetweenInDays only returns positive integers. Should I just compare their tick values? And if so, how can I convert a date (say, 10/16/2013) to ticks? Last edited: Oct 16, 2013
For the first case, how could I determine that? DateUtils.PeriodBetweenInDays only returns positive integers. Should I just compare their tick values? And if so, how can I convert a date (say, 10/16/2013) to ticks?
Erel B4X founder Staff member Licensed User Longtime User Oct 17, 2013 #48 The chosen date is passed to the Closed event: Code: Sub ADP_Closed (Cancelled As Boolean, Date As Long) If Cancelled = False And Date > DateTime.Now Then 'future time End If End Sub
The chosen date is passed to the Closed event: Code: Sub ADP_Closed (Cancelled As Boolean, Date As Long) If Cancelled = False And Date > DateTime.Now Then 'future time End If End Sub
netsistemas Active Member Licensed User Longtime User Nov 4, 2013 #49 how to set the fitst day MONDAY (in spain, the first day on week is MONDAY and the last is SUNDAY).?
netsistemas Active Member Licensed User Longtime User Nov 4, 2013 #50 ok. i view: http://www.b4x.com/android/forum/threads/german-datepicker.29401/#post170622
E enrico Active Member Licensed User Longtime User Dec 3, 2013 #51 I'm trying to add this date picker in a project. I had a label with the date (pic0), but if I add the date picker with : adpDate.Initialize(Me, "adpDate") adpDate.AddToActivity(Activity, lblDate) the label becomes white (pic1 & pic 2) and I don't understand how to keep it transparent
I'm trying to add this date picker in a project. I had a label with the date (pic0), but if I add the date picker with : adpDate.Initialize(Me, "adpDate") adpDate.AddToActivity(Activity, lblDate) the label becomes white (pic1 & pic 2) and I don't understand how to keep it transparent
Erel B4X founder Staff member Licensed User Longtime User Dec 4, 2013 #52 Can you upload your project (File - Export as zip)?
E enrico Active Member Licensed User Longtime User Dec 4, 2013 #53 I couldn't replicate the problem in a clean project. Surely it depends on some of my layouts. I have not been able to solve it and my workaround is to delete this line : Lbl.Background = et.Background in the class module. Another thing is that when I close date picker (with cancel or today), black boxes remains in the buttons place (as you can see in screenshot)
I couldn't replicate the problem in a clean project. Surely it depends on some of my layouts. I have not been able to solve it and my workaround is to delete this line : Lbl.Background = et.Background in the class module. Another thing is that when I close date picker (with cancel or today), black boxes remains in the buttons place (as you can see in screenshot)
S shaffnert03 Member Licensed User Longtime User Dec 8, 2013 #54 Another problem to consider while working through this. If I try to call the setdate function before I've manually opened and closed the date picker, I hit several unitialized variables (targetLabel, Years, Months) and it fails. This is true even though I've initialized the date picker in my code. Is there a fix for this or something I need to do to avoid it?
Another problem to consider while working through this. If I try to call the setdate function before I've manually opened and closed the date picker, I hit several unitialized variables (targetLabel, Years, Months) and it fails. This is true even though I've initialized the date picker in my code. Is there a fix for this or something I need to do to avoid it?
Erel B4X founder Staff member Licensed User Longtime User Dec 8, 2013 #55 The problem happens because there is a call to AddToActivity in DesignerCreateView that is done with CallSubDelayed. It must use CallSubDelayed because it is not possible to load a layout file while a file is being loaded. The solution is to use CallSubDelayed in your code: Code: Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") CallSubDelayed(Me, "SetDate") End Sub Sub SetDate ADP.SetDate(DateTime.Now, True) End Sub
The problem happens because there is a call to AddToActivity in DesignerCreateView that is done with CallSubDelayed. It must use CallSubDelayed because it is not possible to load a layout file while a file is being loaded. The solution is to use CallSubDelayed in your code: Code: Sub Activity_Create(FirstTime As Boolean) Activity.LoadLayout("1") CallSubDelayed(Me, "SetDate") End Sub Sub SetDate ADP.SetDate(DateTime.Now, True) End Sub
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2013 #57 You will need to upload code that reproduces it.
E enrico Active Member Licensed User Longtime User Dec 10, 2013 #58 Erel said: You will need to upload code that reproduces it. Click to expand... I'm thinking if it happens only with the emulator Attachments adp_barx.zip adp_barx.zip 13.9 KB · Views: 644
Erel said: You will need to upload code that reproduces it. Click to expand... I'm thinking if it happens only with the emulator
Erel B4X founder Staff member Licensed User Longtime User Dec 10, 2013 #59 The label background is indeed set to look like an EditText. You can remove this line if you want it to look differently.
The label background is indeed set to look like an EditText. You can remove this line if you want it to look differently.
JTmartins Active Member Licensed User Longtime User Dec 15, 2013 #60 Hello, Been playing with this class and came across this problem in my tablet the label with the date apears correctly with 2013/12/18, just as I want, however in my phone the date in the label shows as 2013/12/18 00:00:00. but this only happens in my app. The sample works OK on the phone and on the tablet Why is the time coming up only on the phone ? (althoug I do understand that the time is part of the string) Tablet : Android 4.03 Phone : 4.1.1 Code: Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) DateTime.DateFormat = "yyyy/MM/dd" Label1.Text= DateUtils.TicksToString(Date) Last edited: Dec 15, 2013
Hello, Been playing with this class and came across this problem in my tablet the label with the date apears correctly with 2013/12/18, just as I want, however in my phone the date in the label shows as 2013/12/18 00:00:00. but this only happens in my app. The sample works OK on the phone and on the tablet Why is the time coming up only on the phone ? (althoug I do understand that the time is part of the string) Tablet : Android 4.03 Phone : 4.1.1 Code: Log("Cancelled = " & Cancelled & ", Date = " & DateUtils.TicksToString(Date)) DateTime.DateFormat = "yyyy/MM/dd" Label1.Text= DateUtils.TicksToString(Date)