Android Question Standard Page Viewer feature or error?

Discussion in 'Android Questions' started by nibbo, Mar 23, 2015.

  1. nibbo

    nibbo Active Member Licensed User

    Hi All

    I am using the standard page viewer to display 'pages' from a catalogue.
    Each page can contain up to 6 items and the user is able to swipe the pages left or right.
    All good except that when sliding the pages I can see the current page behind the page I am swiping to.
    Not a problem if the page is full but when I get to the last page only new entries slide across and I can see the items added to the previous page.
    I have not explained this very well so will try to illustrate:

    If I have 9 items to be viewed page 1 shows:

    1 2 3
    4 5 6

    All good... however if I then swipe the screen left to move to the next page I see:

    7 8 9
    4 5 6

    Why can I still see 4,5 & 6 when these were panels added to page 1 only?

    Thanks in advance for any suggestions...
  2. Erel

    Erel Administrator Staff Member Licensed User

    Something is wrong in the code that you are using to build (or manage) the layout. Hard to say without seeing some of the code.
  3. nibbo

    nibbo Active Member Licensed User

    Hi Erel

    I am sure you a right but I cannot see where the problem is.

    Here is a simplified loop that has been used to populate the viewer panels.
    As you can see from the attachments the problem seems to be that page 1 is always in the back ground!

    Sub ShowStockItems

    '    initialise a standard page viewer and add it to the main panel
    '    set in index to the first page
        Dim iPanel As Int = 0
    '    create a panel array to contain details of each stock code
        Dim P(15As Panel
    '    panel size and positionaing variables
        Dim iGap As Int = 15
    Dim iPanelHeight As Int = 230
    Dim iPanelWidth As Int = 406
    Dim iPanelTop As Int = iGap
    Dim iPanelLeft As Int = iGap
    Dim iTop As Int = iPanelTop
    Dim iLeft As Int = iPanelLeft

    '    display each stock item
        For i = 0 To 14

    '    initialise the panel
    '    add it to the view pager

    '    add a label to see which item this is
            Dim lCode As Label
            lCode.text = i

    '    check to see if we are advancing horizontally, starting a new line or starting a new page
            If (i+1Mod 6 = 0 Then
    '    start a new page
                iTop = iPanelTop
                iLeft = iPanelLeft
                iPanel = iPanel + 
    If (i+1Mod 3 = 0 Then
    '    start new row on current page
                    iTop = iTop + iPanelHeight + iGap
                    iLeft = iPanelLeft
    '    position to next horizontal entry
                    iLeft = iLeft + iPanelWidth + iGap
    End If
    End If

    End Sub
    The attached shows pages 1 and 2 and as you can see page 1 is visible in the background.
    If I move to page 3 page 1 is still visible...


    Attached Files:

  4. Erel

    Erel Administrator Staff Member Licensed User

    iPanelHeight and width should use dip units.

    I don't know whether this is the cause of this problem however you need to add the view pager to the activity.
  5. nibbo

    nibbo Active Member Licensed User

    Tried all of the above but still no change.
    The dip's made no difference and the view pager was already added to the activity in Activity_Create.
    Why would it only affect the first panel?
    Where is the latest library code as it does not appear in the wiki page?
    I am using 1.50, is this the latest version?
  6. nibbo

    nibbo Active Member Licensed User

    I can be so stupid sometimes.
    The code that added the view pager was being executed twice so it actually added two instances of it.
    When I scrolled the top view pager it the first one was still visible behind it...
    Sorry Erel.
  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