B4J Question seting typeface from a veriable in a class

Cableguy

Expert
Licensed User
Longtime User
hi guys,
I'm trying to implement a sub to set the typeface for an array of labels

I first define a typeface variable to dynamically hold the typeface.

B4X:
cgWeekDayLabelFont as TypeFace

Then I set the following sub
B4X:
Public Sub setCalendarWeekDayLabelFont (font As Typeface)
cgWeekDayLabelFont = font
For i = 0 To cgWeekDayLabel.Length -1
cgWeekDayLabel(i).Typeface = cgWeekDayLabelFont
Next
End Sub

But I'm getting a puzzling error :

B4X:
Error occurred on line: 392 (cgCalendar)
java.lang.IllegalArgumentException: method b4a.example.cgcalendar._setcalendarweekdaylabelfont argument 2 has type anywheresoftware.b4a.keywords.constants.TypefaceWrapper, got android.graphics.Typeface
 at java.lang.reflect.Method.invoke(Native Method)
 at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:668)
 at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:334)
 at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:244)
 at java.lang.reflect.Method.invoke(Native Method)
 at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:132)
 at b4a.example.main.afterFirstLayout(main.java:102)
 at b4a.example.main.access$000(main.java:17)
 at b4a.example.main$WaitForLayout.run(main.java:80)
 at android.os.Handler.handleCallback(Handler.java:739)
 at android.os.Handler.dispatchMessage(Handler.java:95)
 at android.os.Looper.loop(Looper.java:148)
 at android.app.ActivityThread.main(ActivityThread.java:5417)
 at java.lang.reflect.Method.invoke(Native Method)
 at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
** Activity (main) Resume **

Please help
 
Top