B4A Library [Class] AnotherDatePicker - A simple "web style" date picker

Status
Not open for further replies.
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:

SS-2016-02-10_17.26.22.png


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:

SS-2016-02-10_17.26.57.png


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
    13.2 KB · Views: 3,553
Last edited:

barx

Well-Known Member
Licensed User
Longtime User
I have updated my attached edit in post #7 to reflect Erels' DateUtils update.
 

WZSun

Member
Licensed User
Longtime User
Hi Erel
If I tap on the '31', it shows "03/31/2013" and I am able to change the date again.

But when I tap on TODAY, it shows '03/31/2013" which is good. BUT I cannot tap on the LABEL1 again. It hung for a while... and sometimes the error "Unfortunately, B4A Example has stopped".

Rgds
WZ
 

barx

Well-Known Member
Licensed User
Longtime User
Are you running the example in the first post?

I would say yes as mine uses a button to trigger the datepicker. I did that for such cases ;)
 

WZSun

Member
Licensed User
Longtime User
Are you running the example in the first post?

Can you post the error from the logs?

Hi Erel,
Not sure whether your question is directed to me...

Anyway... I'm using the latest sample (DateUtils was updated to v1.03) downloaded from 1st post. Steps to repro...
1) Launch sample
2) Tap on Label1 box
3) When calendar pops up, tap on day "20" (or any day)
4) Now Label1 box shows the date (e.g., 03/20/2013)
5) Now tap on Label1 box again
6) Calendar pops up. Tap on TODAY button
7) Label1 now shows "03/31/2013" (eg. at day of testing)
8) Now tap on LABEL1 box again. It hung. Message shows "Unfortunately, B4A Example has stopped"

How do I retrieve the log?
 

WZSun

Member
Licensed User
Longtime User
Hi Erel,
No problem.. I can adapt the codes without the TODAY option...

Anyway, out of curosity, below is the log when I just tried it again (2nd April 2013)
B4X:
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Connected to B4A-Bridge (Wifi)
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
GC_CONCURRENT freed 463K, 11% free 13067K/14599K, paused 4ms+2ms, total 43ms
Connected to B4A-Bridge (Wifi)
GC_CONCURRENT freed 460K, 11% free 13069K/14599K, paused 12ms+3ms, total 45ms
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
java.lang.IndexOutOfBoundsException: Invalid index 113, size is 31
   at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
   at java.util.ArrayList.get(ArrayList.java:304)
   at anywheresoftware.b4a.objects.SpinnerWrapper$B4ASpinnerAdapter.getView(SpinnerWrapper.java:279)
   at android.widget.Spinner.makeAndAddView(Spinner.java:544)
   at android.widget.Spinner.layout(Spinner.java:495)
   at android.widget.Spinner.onLayout(Spinner.java:459)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at anywheresoftware.b4a.BALayout.onLayout(BALayout.java:41)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at anywheresoftware.b4a.BALayout.onLayout(BALayout.java:41)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at anywheresoftware.b4a.BALayout.onLayout(BALayout.java:41)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at anywheresoftware.b4a.BALayout.onLayout(BALayout.java:41)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at android.widget.LinearLayout.setChildFrame(LinearLayout.java:1655)
   at android.widget.LinearLayout.layoutVertical(LinearLayout.java:1513)
   at android.widget.LinearLayout.onLayout(LinearLayout.java:1426)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
   at android.view.View.layout(View.java:14063)
   at android.view.ViewGroup.layout(ViewGroup.java:4655)
   at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:2017)
   at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1838)
   at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1131)
   at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4611)
   at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
   at android.view.Choreographer.doCallbacks(Choreographer.java:555)
   at android.view.Choreographer.doFrame(Choreographer.java:525)
   at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
   at android.os.Handler.handleCallback(Handler.java:615)
   at android.os.Handler.dispatchMessage(Handler.java:92)
   at android.os.Looper.loop(Looper.java:137)
   at android.app.ActivityThread.main(ActivityThread.java:4898)
   at java.lang.reflect.Method.invokeNative(Native Method)
   at java.lang.reflect.Method.invoke(Method.java:511)
   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1008)
   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:775)
   at dalvik.system.NativeStart.main(Native Method)
GC_CONCURRENT freed 482K, 11% free 13072K/14599K, paused 2ms+12ms, total 37ms
sending message to waiting queue (CallSubDelayed - UpdateStatus)
Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
Connected to B4A-Bridge (Wifi)

Ignoring event (too many queued events: CallSubDelayed - UpdateStatus)
GC_CONCURRENT freed 464K, 11% free 13067K/14599K, paused 3ms+5ms, total 51ms
 

RauchG

Active Member
Licensed User
Longtime User
Calendar Weeks

Hi there,

I wish to in Erels "Another Date Picker" View the calendar weeks.

How can I integrate this with?

Can someone please give me jump start.

Greeting RauchG
newbie
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Jump start:

You can use this code in DrawDays to calculate the weeks numbers:
B4X:
Dim firstWeek, lastWeek As Int
   firstWeek = DateTime.GetDayOfYear(DateUtils.SetDate(year, month, 1)) / 7 + 1
   lastWeek = DateTime.GetDayOfYear(DateUtils.SetDate(year, month, daysInMonth)) / 7 + 1
   For week = firstWeek To lastWeek
      Log(week)
   Next
 

realblue

Member
Licensed User
Longtime User
Hi Erel,

Even my device's date format is DD/MM/YYYY ADP displays selected date in MM/DD/YYYY format. What am I doing wrong?

PS : My devices date time settings are :
Automatic date and time (checked)
Automatic time zone (checked)
Language setting is American English
Android version 4.1.2
 
Status
Not open for further replies.
Top