B4A Library AHViewPager library - Sliding panels now perfect

Discussion in 'Additional libraries, classes and official updates' started by corwin42, Jan 18, 2012.

  1. FrenchDeveloper

    FrenchDeveloper Member Licensed User

    Hello and thank you very much for this great lib !

    I just added this code at the end of Activity_Create in ScrollingTabs example :
    For i = 0 To 9
    Dim px As Panel
            px = PC.GetPageObject(i)
            LogColor(i & 
    " - " & px.Width, Colors.Blue)        'line 66
    and I have a strange issue :
    Why does it happen when i = 2 and not before ?
  2. Manuel Martinez

    Manuel Martinez Member Licensed User

    I think is because the pages are not yet created, they are created and destroyed dynamically.

    If you check the logs in the example, you can see that the library keep one after an one before the current page.

    Dim px As Panel
    px = PC.GetPageObject(Position)
    LogColor(Position & 
    " - " & px.Width, Colors.Blue)
    Put this code in the VP_PageCreated method to see the width of the page created.
  3. FrenchDeveloper

    FrenchDeveloper Member Licensed User

    Thank you Manuel for your reply

    I just realised it. Is there a way to prevent the library to destroy pages ? I need to pre load pages because it takes time.
  4. Manuel Martinez

    Manuel Martinez Member Licensed User

    I do not really know. Chek out this from @corwin42

  5. FrenchDeveloper

    FrenchDeveloper Member Licensed User

    I found this way to prevent the library to destroy pages (I have 10 pages) :
    VP.OffscreenPageLimit = 10
    but then, VP_PageCreated event is not raised anymore
  6. Manuel Martinez

    Manuel Martinez Member Licensed User

    You are right, I guess it's because there is no more pages to create.

    If you change VP.OffscreenPageLimit to 5, the page 6 is created after change to page 1.
  7. yolira

    yolira Member Licensed User

    Hi, I get an error. Please can you help me?

    B4A version: 6.80
    Parsing code. (0.01s)
    Compiling code. (1.00s)
    Compiling layouts code. (0.00s)
    Organizing libraries. (0.00s)
    Generating R file. Error
    AndroidManifest.xml:16: error: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.AppCompat').

  8. corwin42

    corwin42 Expert Licensed User

    Do you have the Android Support Repository installed in SDK Manager?
  9. yolira

    yolira Member Licensed User

    I already found. Thank you
  10. leitor79

    leitor79 Active Member Licensed User


    I'm struggling with this from weeks ago. I've changed the behavior of my app several times (caching destroyed items, disabled scrolling, etc) in order to avoid issues but this one I don't understand:

    java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
    The code goes like this:

    Dim p As Panel
    If Paneles(iPeriodoActual).ContainsKey(iDiaActual) = True Then 'i have the panels cached in an array of maps
                    p = Paneles(iPeriodoActual).Get(iDiaActual) 'if i have the item cached, i retrieve it
                    p = CrearGrafica(iDiaActual, iPeriodoActual) 
    'if i don't have it cached, i create it
                    Paneles(iPeriodoActual).Put(iDiaActual, p) 'and then i add it to the cache
                End If
    'either way, i use the remove view to prevent the luke skywalker issue (it has a father and it's alive). I know that this should not be needed when the panel is created, but as I keep getting the error I put it here, I think is does no harm if the panel is new.
                PC.AddPageAt(p, iDiaActual, 0'<- error raises here

    Thank you very much!

    PS: I can't use the new control since I don't have (yet) the new b4a version.
  11. FrenchDeveloper

    FrenchDeveloper Member Licensed User

    I modified slightly the example in the first thread to add the viewpager to a panel instead to the activity. It works until views in the layout are anchored.
    Anchored views disapear.
    'Add the pager to a window
    Activity.AddView(Pnl_Window, 10%x10%y80%x80%y)
        Pnl_Window.Color = 
    0%x0%y, -1, -1)
    Thanks in advance for any help !

    Attached Files:

  12. Roberto P.

    Roberto P. Well-Known Member Licensed User

    Hi everyone
    with android 9, the library gives the following error. can you tell me the reason or you can update the library.

    java.lang.RuntimeException: java.lang.IllegalArgumentException: Cannot set 'scaleX' to Float.NaN
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.PanelWrapper.LoadLayout(PanelWrapper.java:134)

    thank in advance
  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