Android Question app crash at breakpoint

Discussion in 'Android Questions' started by yaniv hanya, Jul 17, 2019.

  1. yaniv hanya

    yaniv hanya Member Licensed User

    Hi
    I have this sub
    Code:
    Sub SetColor   
        
    Dim sp As Panel=Sender
        
    Dim str() As String = Regex.Split(" ",sp.Tag)   
        colorPnl.Color=
    Colors.RGB(str(0),str(1),str(2))
        colorStr=sp.Tag
    End Sub
    and it is running very good.
    but when I put a breakpoint inside the sub
    sp is not initialized, the app crushs
    and i get this log
    java.lang.RuntimeException: Object should first be initialized (Panel).
    at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
    at anywheresoftware.b4a.objects.ViewWrapper.getTag(ViewWrapper.java:261)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:348)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
    at b4a.example.setledcolor._setcolor(setledcolor.java:168)
    at b4a.example.setledcolor._panel5_click(setledcolor.java:322)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
    at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
    at android.view.View.performClick(View.java:5675)
    at android.view.View$PerformClick.run(View.java:22641)
    at android.os.Handler.handleCallback(Handler.java:836)
    at android.os.Handler.dispatchMessage(Handler.java:103)
    at android.os.Looper.loop(Looper.java:203)
    at android.app.ActivityThread.main(ActivityThread.java:6251)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)
    Do you have any idea why
     
  2. Jmu5667

    Jmu5667 Well-Known Member Licensed User

    What is colorPnl ?
     
  3. DonManfred

    DonManfred Expert Licensed User

    what should this line do? there is no sender in a normal sub, only in a button_click event for ex.
     
  4. Jmu5667

    Jmu5667 Well-Known Member Licensed User

    It look like _panel5_click is calling setcolor
     
  5. DonManfred

    DonManfred Expert Licensed User

    It is just a guess.

    Even then it would not work like this.
     
  6. yaniv hanya

    yaniv hanya Member Licensed User

    I have a few buttons that are supposed to change the color of a panel (the colorPnl)
    And all their click events point to this function.
    By identifying the sender I decide which to color to change the panel.
    As mentioned above it works fine but when I try to debug the project and put a breakpoint then it falls.
     
  7. Jmu5667

    Jmu5667 Well-Known Member Licensed User

    can you just send the panel as a parameter to the setcolor function
     
  8. yaniv hanya

    yaniv hanya Member Licensed User

    That's what I did at the end.
    Thanks
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice