Android Question [Solved]Colored the day of week

Theera

Well-Known Member
Licensed User
Longtime User
From Calendar Project ,I would like to color each the days of week. How to code?

B4X:
cvs.DrawText(day, (((dayOfWeekOffset + day - 1) Mod 7) + 0.5) * boxW, _
            (row + 0.5)* boxH + vCorrection, daysFont, SelBGColorDayOfWeek(?), "CENTER")

B4X:
Public Sub SelBGColorDayOfWeek(Digit As Int) As Int
    Dim xBgColor As Int
    Select Digit
        Case 0
            xBgColor=xui.Color_Red
        Case 1
            xBgColor=xui.Color_RGB(241,241,0)
        Case 2
            xBgColor=xui.Color_RGB(241,0,180)
        Case 3
            xBgColor=xui.Color_RGB(80,176,0)
        Case 4
            xBgColor=xui.Color_RGB(252,135,51)
        Case 5
            xBgColor=xui.Color_RGB(0,180,241)
        Case 6
            xBgColor=xui.Color_RGB(168,0,241)
    End Select
    Return xBgColor
End Sub
 

Sagenut

Expert
Licensed User
Longtime User
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
Maybe try in this way
Declare a Map as Global variable
B4X:
Private weekdays As Map = CreateMap("SUNDAY":xui.Color_Red, "MONDAY":xui.Color_RGB(241,241,0), "TUESDAY":xui.Color_RGB(241,0,180), "WEDNESDAY":xui.Color_RGB(80,176,0), "THURSDAY":xui.Color_RGB(252,135,51), "FRIDAY":xui.Color_RGB(0,180,241), "SATURDAY":xui.Color_RGB(168,0,241))
and then
B4X:
cvs.DrawText(day, (((dayOfWeekOffset + day - 1) Mod 7) + 0.5) * boxW, _
            (row + 0.5)* boxH + vCorrection, daysFont, weekdays.Get(day.ToUpperCase), "CENTER")
The SUB SelBGColorDayOfWeek will not be needed anymore.
 
Upvote 0

emexes

Expert
Licensed User
color each the days of week. How to code?

I might be misunderstanding the question, but maybe:

B4X:
cvs.DrawText( _
    day, _
    (((dayOfWeekOffset + day - 1) Mod 7) + 0.5) * boxW, _
    (row + 0.5)* boxH + vCorrection, _
    daysFont, _
    SelBGColorDayOfWeek(?), _
    "CENTER" _
)

replace the ? with (dayOfWeekOffset + day - 1) Mod 7 eg:

B4X:
cvs.DrawText( _
    day, _
    (((dayOfWeekOffset + day - 1) Mod 7) + 0.5) * boxW, _
    (row + 0.5)* boxH + vCorrection, _
    daysFont, _
    SelBGColorDayOfWeek((dayOfWeekOffset + day - 1) Mod 7), _
    "CENTER" _
)
 
Last edited:
Upvote 0

Theera

Well-Known Member
Licensed User
Longtime User
Thank you all of you.
 
Upvote 0
Top