Android Question Type of custom view

Guenter Becker

Active Member
Licensed User
Good Day to you,

may be it is a silly question but yet I do'nt see the wood for the trees.
I developed a XUI Custom View and put the view as a children in a Panel. Now I like to run through the Panel childern and test each returned view ( see code example). For the native views it is working fine. But if I like to test a custom view it fails. I tried also GetType but it is the same result.

Next I tried to get access to a custom property of the custom view and coded a getColumnName public sub. It is shown in the view's context menu but calling it leads to an error (see code).

Questions:
What is a working way to detect the type of a custom view?
How to access a Custom Views custom property.

Thank you for your help.
Best regards Guenter

Example:
For Each cView As View In pnlDataForm.GetAllViewsRecursive

                If cView.tag = "TDextLabel" Then <---- Work around because IF cView is TDextLabel is not working

                    Dim clbl As TDextLabel = cView

                    Log(clbl.ColumnName) <------- ERROR
                .......

' error text:

** Activity (main) Create, isFirst = true **

Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.

** Activity (main) Resume **

Error occurred on line: 199 (B4XMainPage)

java.lang.RuntimeException: Field: ba not found in: anywheresoftware.b4a.BALayout    <------- There is no field ba coded by me!

    at anywheresoftware.b4a.shell.Shell$FieldCache.getField(Shell.java:923)

    at anywheresoftware.b4a.shell.Shell.getField(Shell.java:697)

    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:146)

    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)

    at anywheresoftware.b4a.shell.DebugResumableSub$RemoteResumableSub.resume(DebugResumableSub.java:22)

    at anywheresoftware.b4a.keywords.Common$13.run(Common.java:1717)

    at android.os.Handler.handleCallback(Handler.java:873)

    at android.os.Handler.dispatchMessage(Handler.java:99)

    at android.os.Looper.loop(Looper.java:193)

    at android.app.ActivityThread.main(ActivityThread.java:6669)

    at java.lang.reflect.Method.invoke(Native Method)

    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)

    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
 

Guenter Becker

Active Member
Licensed User
Thank you LucaMS, works fine. Have a nice Day.
Greetings Guenter
 
Upvote 0
Top