Hi there!
I'm writing a class to write text on canvas using layout ... but when I try to set the Typeface by reflector I get an error:
(of course! This is because setTypeface takes a parameter of type Typeface ... but I give it the Typeface of B4A!)
(all other methods I invoke on TP works correctly with int, float and string parameters... but not setTypeface!)
I also tried to take the object inside of the Typeface of B4A ... calling getObject or getObjectOrNull with:
and this is the returned error:
so... there is someone who knows how to properly pass the Typeface via reflector?
thanks in advance
I'm writing a class to write text on canvas using layout ... but when I try to set the Typeface by reflector I get an error:
java.lang.NoSuchMethodException: setTypeface [class java.lang.String]
(of course! This is because setTypeface takes a parameter of type Typeface ... but I give it the Typeface of B4A!)
B4X:
Public Sub SetTypeface(Font As Typeface)
Dim R As Reflector
R.Target = TP ' TP is class private variable of type Object instanced with R.CreateObject("android.text.TextPaint")
R.RunMethod2("setTypeface", Font, "android.graphics.Typeface")
End Sub
(all other methods I invoke on TP works correctly with int, float and string parameters... but not setTypeface!)
I also tried to take the object inside of the Typeface of B4A ... calling getObject or getObjectOrNull with:
B4X:
Public Sub SetTypeface(Font As Typeface)
Dim R As Reflector
R.Target = Font
Dim RealTypeface As Object = R.RunMethod("getObject")
R.Target = TP ' TP is class private variable of type Object instanced with R.CreateObject("android.text.TextPaint")
R.RunMethod2("setTypeface", RealTypeface, "android.graphics.Typeface")
End Sub
and this is the returned error:
java.lang.NoSuchMethodException: getObject []
so... there is someone who knows how to properly pass the Typeface via reflector?
thanks in advance