This is a (partly) wrapper for this Github project. It is a "starter" for the request posted by @jahswani in the Business Forum
Posting the following:
1. B4A project demonstrating functionality added thus far
2. The Java Code - do with it / change it / amend it whichever way you like
3. B4A library files - copy them to your additional library folder
4. You will also need android-support-v4.jar to be in you additional library folder. You can download it from here https://www.dropbox.com/s/qmggn0wm5a6bqa9/android-support-v4.jar?dl=0
How to use:
1. See code in the attached project to add an Event via B4A code
2. Touch and empty cell - it will be highlighted in Yellow (see code to change the color). Then touch the same cell again. An Event will be added to the Calendar based on the B4A code:
3. Use your finger to scroll up/down (time) and left / right (days)
4. The following 3 events will be raised in the B4A project
To change the appearance:
When you touch a cell with an Event that has been set it will display a Toast Message with the name of the Calendar Event and the Detail of the Calendar Event.
The Toast Message is displayed by making use of inline Java code. Therefor you also need to enable the JavaObject (v2.05) library in the IDE.
I will help/assist where I can to amend/change/modify the lib - but I am mostly leaving it up to you to take it further.
Sample code:
The library as it stands at present:
MultiDayCalendarView
Author: Github: Sundeep Kahlon, Wrapped by: Johan Schoeman
Version: 1
Sample pics:
SAMPLE B4A PROJECT STARTED
AN EMPTY CELL TOUCHED - IT IS HIGHLIGHTED IN YELLOW
THE SAME YELLOW HIGHLIGHTED CELL TOUCED AGAIN. AN EVENT IS ADDED (MORNING MEETING)
CELL WITH AN EVENT TOUCHED - A TOAST MESSAGE IS DISPLAYED WITH THE EVENT NAME AND THE EVENT DETAIL (via inline Java Code)
SCROLL LEFT USING YOUR FINGER (SEE THE B4A LOG)
SCROLL RIGHT USING YOUR FINGER (SEE THE B4A LOG)
In order to compile the Java code you need to add a libs folder on the same folder lever as the src folder. Then copy android-support-v4.jar into the libs folder to compile the Java code to a jar and xml
Enjoy.....
Posting the following:
1. B4A project demonstrating functionality added thus far
2. The Java Code - do with it / change it / amend it whichever way you like
3. B4A library files - copy them to your additional library folder
4. You will also need android-support-v4.jar to be in you additional library folder. You can download it from here https://www.dropbox.com/s/qmggn0wm5a6bqa9/android-support-v4.jar?dl=0
How to use:
1. See code in the attached project to add an Event via B4A code
2. Touch and empty cell - it will be highlighted in Yellow (see code to change the color). Then touch the same cell again. An Event will be added to the Calendar based on the B4A code:
B4X:
mdcv1.ClickEventName = "Morning Meeting"
mdcv1.ClickEventDetail = "All Operations Personnel"
mdcv1.ClickEventColor = Colors.DarkGray
4. The following 3 events will be raised in the B4A project
B4X:
Sub mdcv1_event_selected(eventname As String, eventdetail As String)
Log("B4A: calendar eventname = " & eventname)
Log("B4A: calendar eventdetail = " & eventdetail)
nativeMe.RunMethod("showToastMessage", Array(eventname & " : " & eventdetail))
End Sub
Sub mdcv1_calendar_scrolling(firstday As String)
Log("B4A: first day = " & firstday)
End Sub
Sub mdcv1_event_added(eventstartdatetime As Long, clickeventname As String, clickeventdetail As String, clickeventcolor As Int)
Log("B4A : eventstartdatetime = " & eventstartdatetime)
Log("B4A : clickeventname = " & clickeventname)
Log("B4A : clickeventdetail = " & clickeventdetail)
Log("B4A : clickeventcolor = " & clickeventcolor)
End Sub
To change the appearance:
B4X:
mdcv1.DefaultEventSelectColor = Colors.Yellow
mdcv1.DayOfMonthTextSize = 40
mdcv1.DayOfWeekTextSize = 25
mdcv1.TimeTextSize = 18
mdcv1.EventTextSize = 20
When you touch a cell with an Event that has been set it will display a Toast Message with the name of the Calendar Event and the Detail of the Calendar Event.
The Toast Message is displayed by making use of inline Java code. Therefor you also need to enable the JavaObject (v2.05) library in the IDE.
I will help/assist where I can to amend/change/modify the lib - but I am mostly leaving it up to you to take it further.
Sample code:
B4X:
#Region Project Attributes
#ApplicationLabel: MultiDayCalendarView
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#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.
Dim nativeMe As JavaObject
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 mdcv1 As MultiDayCalendarView
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")
nativeMe.InitializeContext
mdcv1.ClickEventName = "Morning Meeting"
mdcv1.ClickEventDetail = "All Operations Personnel"
mdcv1.ClickEventColor = Colors.DarkGray
mdcv1.DefaultEventSelectColor = Colors.Yellow
mdcv1.DayOfMonthTextSize = 40
mdcv1.DayOfWeekTextSize = 25
mdcv1.TimeTextSize = 18
mdcv1.EventTextSize = 20
End Sub
Sub Activity_Resume
Dim tim As Long = DateTime.TimeZoneOffset * 60 * 60 * 1000
' tim = tim + DateTime.Now - DateTime.GetMinute(DateTime.Now) * 60 * 1000 - DateTime.GetSecond(DateTime.Now) * 1000
' tim = tim/1000
DateTime.DateFormat = "yyyy/MM/dd"
DateTime.TimeFormat = "HH:mm:ss"
tim = tim + DateTime.DateTimeParse("2016/04/18", "18:00:00") 'tim = in milliseconds
tim = tim/1000 'tim = converted to seconds
mdcv1.addEvent(tim, "Supper with John", "The Butcher Boys", Colors.Blue) 'seconds need to be passed
'mdcv1.removeEvent(tim) 'this will remove the same event that we have just set in the line above
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub mdcv1_event_selected(eventname As String, eventdetail As String)
Log("B4A: calendar eventname = " & eventname)
Log("B4A: calendar eventdetail = " & eventdetail)
nativeMe.RunMethod("showToastMessage", Array(eventname & " : " & eventdetail))
End Sub
Sub mdcv1_calendar_scrolling(firstday As String)
Log("B4A: first day = " & firstday)
End Sub
Sub mdcv1_event_added(eventstartdatetime As Long, clickeventname As String, clickeventdetail As String, clickeventcolor As Int)
Log("B4A : eventstartdatetime = " & eventstartdatetime)
Log("B4A : clickeventname = " & clickeventname)
Log("B4A : clickeventdetail = " & clickeventdetail)
Log("B4A : clickeventcolor = " & clickeventcolor)
End Sub
#If Java
import android.widget.Toast;
//this will display a Toast Message (Event Name and Event Detail) when a cell containing an Event is touched
public void showToastMessage(String message) {
Toast.makeText(BA.applicationContext, message, Toast.LENGTH_SHORT).show();
}
#End If
The library as it stands at present:
MultiDayCalendarView
Author: Github: Sundeep Kahlon, Wrapped by: Johan Schoeman
Version: 1
- MultiDayCalendarView
Events:- calendar_scrolling (firstdateshown As String)
- event_added (eventstartdatetime As Long, clickeventname As String, clickeventdetail As String, clickeventcolor As Int)
- event_selected (eventname As String, eventdetail As String)
- ba As BA
- BringToFront
- DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
- Initialize (EventName As String)
- 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)
- addEvent (seconds As Long, Eventname As String, detail As String, color As Int)
Add an Event to the calendar
The date and time converted to seconds (use the date and hour only - make minutes and seconds zero)
Eventname = the name of the Event
detail = the detail of the event
color = the color of the cell that houses the Event - removeEvent (epochTimeInSecsToTheClosetHour As Long)
Remove an Event from the Calendar
epochTimeInSecsToTheClosetHour should be in "seconds"
- Background As Drawable
- ClickEventColor As Int [write only]
- ClickEventDetail As String [write only]
- ClickEventName As String [write only]
- Color As Int [write only]
- DayOfMonthTextSize As Int [write only]
Default is 23 - DayOfWeekTextSize As Int [write only]
Default is 15 - DefaultEventSelectColor As Int [write only]
The color of an empty cell to chenge to when it is clicked on
If you touch the same cell again an event will be added
The event that will be added is based on what have been set with:
ClickEventName = clickeventname,
ClickEventDetail = clickeventdetail, and
ClickEventColor = clickeventcolor - Enabled As Boolean
- EventTextSize As Int [write only]
Default is 13 - Height As Int
- Left As Int
- Parent As Object [read only]
- Tag As Object
- TimeTextSize As Int [write only]
Default is 13 - Top As Int
- Visible As Boolean
- Width As Int
Sample pics:
SAMPLE B4A PROJECT STARTED
AN EMPTY CELL TOUCHED - IT IS HIGHLIGHTED IN YELLOW
THE SAME YELLOW HIGHLIGHTED CELL TOUCED AGAIN. AN EVENT IS ADDED (MORNING MEETING)
CELL WITH AN EVENT TOUCHED - A TOAST MESSAGE IS DISPLAYED WITH THE EVENT NAME AND THE EVENT DETAIL (via inline Java Code)
SCROLL LEFT USING YOUR FINGER (SEE THE B4A LOG)
SCROLL RIGHT USING YOUR FINGER (SEE THE B4A LOG)
In order to compile the Java code you need to add a libs folder on the same folder lever as the src folder. Then copy android-support-v4.jar into the libs folder to compile the Java code to a jar and xml
Enjoy.....
Attachments
Last edited: