Android Question [Solved] Dynamic Paging

AHilberink

Active Member
Licensed User
Longtime 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é
 

AHilberink

Active Member
Licensed User
Longtime User
2. You can do it in the PageSelected event.

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é
 
Upvote 0

AHilberink

Active Member
Licensed User
Longtime 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:
B4X:
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(100) As 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é
 

Attachments

  • TabStripTest.zip
    6.4 KB · Views: 266
Upvote 0
Top