Android Question [Solved] Dynamic Paging

Discussion in 'Android Questions' started by AHilberink, May 15, 2019.

  1. AHilberink

    AHilberink Active Member Licensed User

    Hi,

    For my project I need Slinding tabs. Every tab is a record from my database. The user can change data on the tab. All tabs are filled with the same panel/layout.

    I have a few questions/difficulties:
    1. What can use best for this: TabStrip or AHViewPager?
    2. I need to save changed data on leaving the tab and reload on every next tab. Can this be done?
    3. Is there a way to reset all objects used at once or do I need to clear them one by one progammaly?

    Thanks in advange for helping me.

    Best regards,
    André
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    2. You can do it in the PageSelected event.
    3. Panel.RemoveAllViews followed by Panel.LoadLayout.
     
    AHilberink likes this.
  3. AHilberink

    AHilberink Active Member Licensed User

    Thanks!!
     
  4. AHilberink

    AHilberink Active Member Licensed User

    Hi,

    How can I define about 20 tabs? Tabstrip.LoadLayout(..,..) needs a layout to load. Giving them all the same layout: Only the last has the changes made in PageSelected event. Tried it with a Panel on the layout, same result.

    Do I need to make 20 layoutfiles in advange or is there a way to do the changes only on the active page as PageSelected?

    Best regards,
    André
     
  5. AHilberink

    AHilberink Active Member Licensed User

    Hi,

    I find a solution for this problem with the use of TabStripViewPagerExtendet, with which I can add Panels instead of layouts.

    My source:
    Code:
    ub Globals
        
    'These global variables will be redeclared each time the activity is created.
        'These variables can only be accessed from this module.

        
    Private TabStrip1 As TabStrip
        
    Private CurrentPage As Int
        
    Private Panel1Dump(100As Panel
        
    Private Label1 As Label
        
    Private CheckBox1 As CheckBox
    End Sub

    Sub Activity_Create(FirstTime As Boolean)
        
    Activity.LoadLayout("Main")
        
        
    For i=0 To 20
            Panel1Dump(i).Initialize(Me)
            TabStripExt.InsertPage(TabStrip1,i,Panel1Dump(i),
    "Titel"&i)
        
    Next
        TabStrip1_PageSelected(
    0)
    End Sub

    Sub TabStrip1_PageSelected (Position As Int)
        
    Log($"Current page: ${Position}"$)

        Panel1Dump(CurrentPage).RemoveAllViews
        Panel1Dump(Position).LoadLayout(
    "Leeg")
        Label1.Text=Label1.Text&
    ": "&Position
        CurrentPage=Position
    End Sub

    Sub Activity_Resume

    End Sub

    Sub Activity_Pause (UserClosed As Boolean)

    End Sub

    Sub CheckBox1_CheckedChange(Checked As Boolean)
        
    If(Checked) Then
            Label1.Visible=
    False
        
    Else
            Label1.Visible=
    True
        
    End If
    End Sub
    You can find it the Extended source on:
    https://www.b4x.com/android/forum/threads/tabstripviewpagerextendet.88821/

    Attached you wil find my complete test project.

    May be usefull for someone.

    Best regards,
    André
     

    Attached Files:

    José J. Aguilar likes this.
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