Android Question Error in B4XViewWrapper

bocker77

Active Member
Licensed User
Longtime User
I am getting this error for the following code.

For Each ckb As AS_CheckboxAdvanced In p
src\AA\Adjunct\b4xmainpage.java:6666: error: incompatible types: B4XViewWrapper cannot be converted to IterableList
group62 = _p;
^
1 error

B4X:
    For Each ckb As AS_CheckboxAdvanced In p
        ckb.Enabled = False
    Next

The panel p is created to be used in a dialog.

B4X:
    Dim p As B4XView = xui.CreatePanel("")
    p.SetLayoutAnimated(0, 0, 0, 300dip, 220dip) 'set the content size
    p.LoadLayout("DeclareWar")
    Dim rs As ResumableSub = Dialog.ShowCustom(p, "Yes", "No", "")
    Wait For (rs) Complete (Result As Int)
    If Result = xui.DialogResponse_Positive Then
        ...
    End If

Is there another way to iterate through the checkboxes? There are not too many of them so I could just disable each individually. But now I am just curious!
 

bocker77

Active Member
Licensed User
Longtime User
I received this error on the statement in line 2 above.

Error occurred on line: 1530 (B4XMainPage)
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference
at anywheresoftware.b4a.shell.Shell.getCorrectClassName(Shell.java:617)
at anywheresoftware.b4a.shell.Shell.getField(Shell.java:694)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:360)
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.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:275)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:150)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:201)
at anywheresoftware.b4a.keywords.Common$15.run(Common.java:1804)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:247)
at android.app.ActivityThread.main(ActivityThread.java:8676)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)

The views are defined here.
B4X:
    Private ckbGermany As AS_CheckboxAdvanced
    Private ckbUSSR As AS_CheckboxAdvanced
    Private ckbJapan As AS_CheckboxAdvanced
    Private ckbUS As AS_CheckboxAdvanced
    Private ckbUKPac As AS_CheckboxAdvanced
Do I need to change these to B4XViews?

Please don't spend too much time on this though. You have much more important things to do. But thanks for responding!
 
Upvote 0

bocker77

Active Member
Licensed User
Longtime User
I did try Erel's suggestion and received the error in message #3.

I just do this and it is working just fine. Thank goodness I don't have many of them.
B4X:
    ckbGermany.Enabled = False
    ckbUSSR.Enabled = False
    ckbJapan.Enabled = False
    ckbUS.Enabled = False
    ckbUKPac.Enabled = False
 
Upvote 0

teddybear

Well-Known Member
Licensed User
I did try Erel's suggestion and received the error in message #3.
You can use this code, it should work:
B4X:
    For i=0 To p.NumberOfViews-1
        p.GetView(i).Tag.As(AS_CheckboxAdvanced).Enabled = False
    Next
 
Upvote 0
Top