Android Question B4XSwitch - I can't programmatically set the state

tsteward

Well-Known Member
Licensed User
Longtime User
The following command on a b4xswitch throws an error

Switchrbtn10cut.mbase.checked = false

*** Receiver (httputils2service) Receive (first time) ***
Tools loading
*** page tool: B4XPage_Created [mainpage]
*** mainpage: B4XPage_Disappear [mainpage]
*** page tool: B4XPage_Appear [mainpage]
Error occurred on line: 542 (B4XPageTool)
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to android.widget.CompoundButton
at anywheresoftware.b4a.objects.B4XViewWrapper.setChecked(B4XViewWrapper.java:307)
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:157)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at lishi.assistand.tony.stewardgmail.com.b4xpagetool._loadpage(b4xpagetool.java:222)
at lishi.assistand.tony.stewardgmail.com.b4xmainpage._clvtools_itemclick(b4xmainpage.java:7623)
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:157)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1114)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1077)
at b4a.example3.customlistview$ResumableSub_PanelClickHandler.resume(customlistview.java:805)
at b4a.example3.customlistview._panelclickhandler(customlistview.java:748)
at b4a.example3.customlistview._panel_click(customlistview.java:735)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:221)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:7658)
at android.view.View.performClickInternal(View.java:7635)
at android.view.View.-$$Nest$mperformClickInternal(Unknown Source:0)
at android.view.View$PerformClick.run(View.java:30167)
at android.os.Handler.handleCallback(Handler.java:958)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:205)
at android.os.Looper.loop(Looper.java:294)
at android.app.ActivityThread.main(ActivityThread.java:8248)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)
 

DonManfred

Expert
Licensed User
Longtime User
Where is the small testproject showing the problem?
 
Upvote 0

tsteward

Well-Known Member
Licensed User
Longtime User
There isn't one yet. Have I set it correctly?
 
Upvote 0
Top