Android Question [SOLVED]Try to use TabStripViewPagerExtendet?

Discussion in 'Android Questions' started by nanjidusan, Feb 26, 2019.

  1. nanjidusan

    nanjidusan Member Licensed User

    When I use SetTabLeft(tabstrip As TabStrip,left As Int,Position As Int)
    Code:
    panel.Initialize("")
        
    Activity.AddView(panel,0,0,100%x,90%y)
        
    panel.LoadLayout("tabstrip")
        tabstrip1.LoadLayout(
    "shengmu","page1")
        tabstrip1.LoadLayout(
    "yunmu","page2")
        tabstrip1.LoadLayout(
    "shengdiao","page3")
        
    panel.Visible=False
        tabstripview.SetTabLeft(tabstrip1,
    20dip,tabstrip1.CurrentPage)
    throws this:
    Code:
    ** Activity (main) Resume **
    ** 
    Activity (main) Create, isFirst = true **
    Panel size is unknown. Layout may not be loaded correctly.
    Error occurred on line: 
    200 (tabstripview)
    java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast 
    to anywheresoftware.b4a.BALayout$LayoutParams
        at anywheresoftware.b4a.objects.ViewWrapper.setLeft(ViewWrapper.java:
    182)
        at dh.apk.tabstripview._settableft(tabstripview.java:
    79)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    372)
        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 java.lang.reflect.Method.invoke(Method.java:
    372)
        at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:
    144)
        at dh.apk.main.afterFirstLayout(main.java:
    104)
    How to solve this problem?
     
  2. nanjidusan

    nanjidusan Member Licensed User

    Code:
    Public Sub SetTabLeft(tabstrip As TabStrip,left As Int,Position As Int)
        
        
    Dim i As Int
        
    For Each lbl As Label In GetAllTabLabels(tabstrip)
            
    If i = Position Then
                
                lbl.Left = left

            
    End If
            i = i + 
    1
        
    Next
        
    End Sub
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    You shouldn't see this warning: Panel size is unknown. Layout may not be loaded correctly.

    It means that the layout will not work properly.

    What is SetTabLeft supposed to do?
     
  4. nanjidusan

    nanjidusan Member Licensed User

    Thanks.
    Code:
    panel.Initialize("panel")
    Activity.AddView(panel,0,0,100%x,90%y)
    panel.LoadLayout("tabstrip")
    tabstrip1.LoadLayout(
    "shengmu","page1")
    tabstrip1.LoadLayout(
    "yunmu","page2")
    tabstrip1.LoadLayout(
    "shengdiao","page3")
    tabstripview.SetTabLeft(tabstrip1,
    20dip,tabstrip1.CurrentPage)
    It hasn't a warning about panel size
    Code:
    ** Activity (main) Create, isFirst = true **
    Error occurred on line: 
    200 (tabstripview)
    java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast 
    to anywheresoftware.b4a.BALayout$LayoutParams
        at anywheresoftware.b4a.objects.ViewWrapper.setLeft(ViewWrapper.java:
    182)
        at dh.apk.tabstripview._settableft(tabstripview.java:
    79)
        at java.lang.reflect.Method.invoke(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:
    372)
        at anywheresoftware.b4a.shell.Shell.runMethod(
    Shell.java:732)
        at anywheresoftware.b4a.shell.Shell.raiseEventImpl(
    Shell.java:348)
    I guess that's not the problem. when use SetTabHeight(tabstrip As TabStrip,height As Int,Position As Int),it works well.
     
  5. nanjidusan

    nanjidusan Member Licensed User

    I don't think the lbl.Left = left in tabstrip will work.
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    What are you trying to do?
     
  7. nanjidusan

    nanjidusan Member Licensed User

    I can't adjust their positions,and the Sub CenterAllTabs can't give me what I need.
     
  8. nanjidusan

    nanjidusan Member Licensed User

    I want to center the label like this tab.png
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    Dim jo As JavaObject = TabStrip1
    Dim hsv As HorizontalScrollView = jo.GetFieldJO("tabStrip")
    hsv.Left = 
    20%x
    hsv.Width = 
    60%x
     
  10. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    or this:
    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

    For Each lbl As Label In Main.fun.GetAllTabLabels(ts_main)
            lbl.Width = 
    Round(Activity.Width/3)
        
    Next
     
  11. nanjidusan

    nanjidusan Member Licensed User

    It works well! Thank you very much, It's very kind of you! Thanks a lot!
     
  12. nanjidusan

    nanjidusan Member Licensed User

    Thanks a lot! But it's full, not in the center as I thought.
     
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