Android Question TabStrip Error "Field: tabstrip not found"

cdsincfl

Member
Licensed User
Longtime User
Using B4A 10.5

Compiled the TabStripViewPager example and it works great.
Added the code below:

Sample code:
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List
    Dim jo As JavaObject = tabstrip
    Dim r As Reflector
    r.Target = jo.GetField("tabstrip")
    Dim tc As Panel = r.GetField("tabsContainer")
    Dim res As List
    res.Initialize
    For Each v As View In tc
        If v Is Label Then res.Add(v)
    Next
    Return res
  
End Sub

I get this error:

java.lang.RuntimeException: Field: tabstrip not found in: anywheresoftware.b4a.objects.TabStripViewPager
at anywheresoftware.b4j.object.JavaObject$FieldCache.getField(JavaObject.java:306)
at anywheresoftware.b4j.object.JavaObject.GetField(JavaObject.java:181)
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.BA.raiseEvent2(BA.java:197)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at b4a.example.main._getalltablabels(main.java:466)
at b4a.example.main._tabstrip1_pageselected(main.java:574)
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$1.run(BA.java:352)
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:6702)
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:911)

Haven't changed anything other than adding the code above.
Need help finding the problem.
 

Mahares

Expert
Licensed User
Longtime User
Try this one that works for me, although they appear similar:
B4X:
Public Sub GetAllTabLabels (tabstrip As TabStrip) As List  'mahares
    Dim jo As JavaObject = tabstrip
    Dim r As Reflector
    r.Target = jo.GetField("tabStrip")
    Dim tc As Panel = r.GetField("tabsContainer")
    Dim res As List
    res.Initialize
    For Each v As View In tc
        If v Is Label Then res.Add(v)
    Next
    Return res
End Sub
 
Upvote 0

cdsincfl

Member
Licensed User
Longtime User
Thanks Mahares for the help.
I needed to change "tabstrip" to "tabStrip".
Got caught with the case sensitivity.
 
Upvote 0
Top