B4A Library CollapseCalendarView

It warps this Github project. Posting the following:

1. B4A project demonstrating CollapseCalendarView
2. The Java code - change/amend it to your liking
3. B4A library files (CollapseCalendarViewLibFiles.zip) - extract the zip file and copy the files to your additional library folder
4. commons-lang3-3.4.zip - extract the zip file and copy the files to your additional library folder
5. joda-time-2.0.zip - extract the zip file and copy the files to your additional library folder

You also need android-support-v4.jar. You can download it from here:
(https://www.dropbox.com/s/qmggn0wm5a6bqa9/android-support-v4.jar?dl=0)

Take note of the files in the Objects/res/blabla.... folders in case you start a new project. The property of these files should be set to READ ONLY

Once you have set up the calendar you can Click on the left / right arrows to go to the next / previous month.

Default calendar view:

1.png


Clicking on the right arrow:

3.png



Fling the view up/down with your finger to get a week view.
Week view:

2.png


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

#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 ccv1 As CollapseCalendarView
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")
    ccv1.Initialize("ccv1", 2, 1)
    Activity.AddView(ccv1, 2%x, 5%y, 96%x, 70%y)
 
    ccv1.DayNameColor = Colors.yellow
    ccv1.DayNameTextSize = 15
 
    ccv1.TitleTextColor = Colors.Green
    ccv1.TitleTextSize = 20
 
 

End Sub

Sub Activity_Resume
 
    Log("resume " & ccv1.SelectedDate)
'    ccv1.minusMonths = 3      'use these two calls together to set the number of months forward/backwards from the present date
'    ccv1.plusMonths = 3

'   ccv1.minusYears = 1       'use these two calls together to set the number of years forward/backwards from the present date
'   ccv1.plusYears = 2
 
    'ccv1.setminusMonthsPlusYears(3,1)    'use this call to set the number of months backwards and the number of years forward from the present date
    ccv1.setminusYearsPlusMonths(1, 5)    'use this call to set the number of years backwards and the number of months forward from the present date
 

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub ccv1_date_selected(mydate As String)
    Log("mydate = " & mydate)
End Sub


The library as it stands at present:
CollapseCalendarView
Author:
Github: Blaz Solar, Wrapped by: Johan Schoeman
Version: 1
  • CollapseCalendarView
    Events:
    • date_selected (date As String)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • Initialize (EventName As String, minusyears As Int, plusyears As Int)
      Initialize with the name of the Event that will be raised when a date is clicked,
      the number of years backwards from the present date (0, 1, 2, 3......), and
      the number of years forward from the present date (0, 1, 2, 3......)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • setminusMonthsPlusYears (minusmonths As Int, plusyears As Int)
      Set the number of months back and the number of years forward from the present date
      This is the range that the calendar will display
    • setminusYearsPlusMonths (minusyears As Int, plusmonths As Int)
      Set the number of years back and the number of months forward from the present date
      This is the range that the calendar will display
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • DayNameColor As Int [write only]
      Set the color of the Day names
    • DayNameTextSize As Int [write only]
      Set the size of the Day names
    • Enabled As Boolean
    • Height As Int
    • Left As Int
    • MaxDate As String [read only]
      Returns the maximum date that the calendar has been set to
    • MinDate As String [read only]
      Returns the minimum date that the calendar has been set to
    • Parent As Object [read only]
    • SelectedDate As String [read only]
      Returns the date that has been clicked on
    • Tag As Object
    • TitleTextColor As Int [write only]
      Set the color of the Title Text (i.e the Month/Year and the Week Number)
    • TitleTextSize As Int [write only]
      Set the size of the Title Text (i.e the Month/Year and the Week Number)
    • Top As Int
    • Visible As Boolean
    • Width As Int
    • minusMonths As Int [write only]
      Set the number of months backwards from the present date
      This method should be used with "plusMonths = x" where x = 0, 1, 2, 3, .....
      The range that the calendar will display will be from (present date - minusmonths) to (present date + plusmonths)
    • minusYears As Int [write only]
      Set the number of years backwards from the present date
      This method should be used with "plusYears = x" where x = 0, 1, 2, 3, .....
      The range that the calendar will display will be from (present date - minusyears) to (present date + plusyears)
    • plusMonths As Int [write only]
      Set the number of months forward from the present date
      This method should be used with "minusMonths = x" where x = 0, 1, 2, 3, .....
      The range that the calendar will display will be from (present date - minusmonths) to (present date + plusmonths)
    • plusYears As Int [write only]
      Set the number of years forward from the present date
      This method should be used with "minusYears = x" where x = 0, 1, 2, 3, .....
      The range that the calendar will display will be from (present date - minusyears) to (present date + plusyears)
 

Attachments

  • b4aCollapseCalendarView.zip
    37.3 KB · Views: 488
  • TheJavaCode.zip
    51.5 KB · Views: 430
  • commons-lang3-3.4.zip
    402.3 KB · Views: 460
  • joda-time-2.0.zip
    470.5 KB · Views: 500
  • CollapseCalendarViewLibFiles.zip
    36.6 KB · Views: 512
Last edited:

wizard699

Active Member
Licensed User
Longtime User
When compiling ..... there is an error: No resource identifier found for attribute 'textAllCaps'
 

Johan Schoeman

Expert
Licensed User
Longtime User
But i've compiled your project ... and all res are READ ONLY.
Do you have files in each of the following folders of the B4A project:
1. /Objects/res/drawable (13 files)
2. /Objects/res/values (4 files)
3. /Objects/res/layout (3 files)
4. /Objects/res/color (1 files)
 

wizard699

Active Member
Licensed User
Longtime User
Yes, all files are present. There is the original structure of your file ZIP. But when open your example and compile ... there are a loto of error like "No resource identifier found for attribute 'textAllCaps'".

Anyone have the same problem?
 

Johan Schoeman

Expert
Licensed User
Longtime User
P
Yes, all files are present. There is the original structure of your file ZIP. But when open your example and compile ... there are a loto of error like "No resource identifier found for attribute 'textAllCaps'".

Anyone have the same problem?
please post the complete error log - do you have a recent version of android-support-v4.jar in your additional library folder? Did you also download all the other libraries and copied them to your additional library folder (as per post #1).
 

wizard699

Active Member
Licensed User
Longtime User
Yes ... all ZIP files are copied in Additina Library.
Here is the error log

Compiling layouts code. (0.02s)
Generating R file. Error
res\layout\calendar_layout.xml:66: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:76: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:86: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:96: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:106: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:116: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:126: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes ... all ZIP files are copied in Additina Library.
Here is the error log

Compiling layouts code. (0.02s)
Generating R file. Error
res\layout\calendar_layout.xml:66: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:76: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:86: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:96: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:106: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:116: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:126: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
Not sure what is the cause of the problem that you are experiencing. What does your B4A "Configure Paths" look Like? What "android.jar" are you making use of?

4.png
 

Johan Schoeman

Expert
Licensed User
Longtime User
Yes ... all ZIP files are copied in Additina Library.
Here is the error log

Compiling layouts code. (0.02s)
Generating R file. Error
res\layout\calendar_layout.xml:66: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:76: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:86: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:96: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:106: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:116: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
res\layout\calendar_layout.xml:126: error: No resource identifier found for attribute 'textAllCaps' in package 'android'
It is also working on my Tablet with Android 4.0.4

5.png
 

achtrade

Active Member
Licensed User
Longtime User
how to know if the calendar is in a week view or not ? or better yet, how to capture the event to make it week view or not ?
 

Shay

Well-Known Member
Licensed User
Longtime User
Hi, how can I change the month and days language and start the week from Sunday and not Monday?
 
Top