Android Question Error: java.lang.RuntimeException: Constructor not found

Amir__Gheibi

New Member
hi, everyone
i have a problem in use SweepGradient , can anyone help?
line 10 InitializeNewInstance "android.graphics.SweepGradient"
B4X:
    Dim Clr(3) As Int
    Clr(0)=Colors.Red
    Clr(1)=Colors.Yellow
    Clr(2)=Colors.green
    DrawGradient(Canvas, 100, 100, 0, 0, Clr, Array As Float(0,1), 5dip, 1, 2)
B4X:
Sub DrawGradient(BG As Canvas, X1 As Float, Y1 As Float, X2 As Float, Y2 As Float, TheColors() As Int,Positions() As Float, StrokeWidth As Float, TileModeInt As Int, GradientType As Int)
    Dim Paint As JavaObject,LinearGradient As JavaObject, CanvJO As JavaObject = BG, TileMode As String = "CLAMP"
    Select Case TileModeInt
        Case 1: TileMode = "MIRROR"
        Case 2: TileMode = "REPEAT"
    End Select
    Select Case GradientType
        Case 0: LinearGradient.InitializeNewInstance("android.graphics.LinearGradient",   Array As Object(X1,Y1, X2,Y2,TheColors,Positions,TileMode))'Linear
        Case 1: LinearGradient.InitializeNewInstance("android.graphics.RadialGradient",   Array As Object(X1,Y1, X2,TheColors,Positions,TileMode))'Radial
        Case 2: LinearGradient.InitializeNewInstance("android.graphics.SweepGradient",    Array As Object(X1,Y1,TheColors,Positions,TileMode))'Sweep
    End Select
    Paint.InitializeNewInstance("android.graphics.Paint",Null)
    Paint.RunMethod("setStrokeWidth",    Array As Object(StrokeWidth))
    Paint.RunMethod("setAntiAlias",    Array As Object(True))
    Paint.RunMethod("setShader",       Array As Object(LinearGradient))
    CanvJO = CanvJO.GetField("canvas")
    CanvJO.RunMethod("drawLine",       Array As Object(X1,Y1,X2,Y2,Paint))
End Sub

i have this error:
B4X:
java.lang.RuntimeException: java.lang.RuntimeException: Constructor not found.
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1706)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6138)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:893)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:783)
Caused by: java.lang.RuntimeException: Constructor not found.
    at anywheresoftware.b4j.object.JavaObject.InitializeNewInstance(JavaObject.java:94)
    at b4a.example.m2._vvv1(m2.java:458)
    at b4a.example.m2$ResumableSub_Activity_Create.resume(m2.java:402)
    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1704)
    ... 7 more
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0
Top