Android Question Tabstrip changing data values on layouts (SOLVED)

Colin Evans

Active Member
Licensed User
I'm sure it's something obvious but I can't figure out where I'm going wrong,

I'm using the tabstrip to swipe between various layouts and I wish to load data from a JSON file, I've designed the layouts and loaded them
B4X:
Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("frmmain")
    TabStrip1.LoadLayout("ScrollView", "Intro")
    ScrollView1.Panel.Height = 600dip
    ScrollView1.Panel.LoadLayout("intro")
    TabStrip1.LoadLayout("ScrollView", "Day1")
    ScrollView1.Panel.Height = 1400dip
    ScrollView1.Panel.LoadLayout("day1")
    TabStrip1.LoadLayout("ScrollView", "Day2")
    ScrollView1.Panel.Height = 1400dip
    ScrollView1.Panel.LoadLayout("day2")
    TabStrip1.LoadLayout("ScrollView", "Day3")
    ScrollView1.Panel.Height = 1400dip
    ScrollView1.Panel.LoadLayout("day3")
    TabStrip1.LoadLayout("ScrollView", "Day4")
    ScrollView1.Panel.Height = 1400dip
    ScrollView1.Panel.LoadLayout("day4")
    TabStrip1.LoadLayout("ScrollView", "Day5")
    ScrollView1.Panel.Height = 1400dip
    ScrollView1.Panel.LoadLayout("day5")
    configtabstrip
End Sub

And I've loaded the JSON data but I can't find a way to populate the various days, a sample JSON
B4X:
For i = 1 To 5
            Dim strI As String = i
            Dim d1 As Map = day.Get(strI)
            days(i) = d1.Get("date")
            rain(i) = d1.Get("rain")
            symbolV(i) = d1.Get("symbol_value")
            Dim sun As Map = d1.Get("sun")
            sunrise(i) = sun.Get("in")
            sunset(i) = sun.Get("out")
            tempmax(i) = d1.Get("tempmax")
Next

Does anyone have any idea they could pass my way to populate the various pages

I've tried the following from an example but it doesn't populate the layouts

B4X:
Sub TabStrip1_PageSelected (Position As Int)
    Log("Page current is " & Position &".Please add any code to make something!!")
    lbl00Description.Text = symbolV(Position)
    lblDate.Text = days(Position)
    lblMTemp.Text = tempmax(Position)
    lblSrise.Text = sunrise(Position)
    lblSSet.Text = sunset(Position)
    lblMRise.Text = moonrise(Position)
    lblMSet.Text = moonset(Position)
End Sub

Appreciate some guidance, if it can be done, thanks
 

Colin Evans

Active Member
Licensed User
Still can't find a way to update the layouts as I swipe across the tabstrip but there must be a way as I've seen it used similarly in other applications, could someone help, please
 
Upvote 0

Colin Evans

Active Member
Licensed User
Is there any one that can help, I've amended the code that shows the tabstrip position to include some logs and it seems to be working but not displaying in the layouts
B4X:
Sub TabStrip1_PageSelected (Position As Int)
    Log("Page current is " & Position )
    lblDescription.Text = symbolV(Position)
    Log(symbolDesc(Position))
    lblDate.Text = days(Position)
    Log(days(Position))
    lblMTemp.Text = tempmax(Position)
    Log(tempmax(Position))
    lblSrise.Text = sunrise(Position)
    Log(sunrise(Position))
    lblSSet.Text = sunset(Position)
    lblMRise.Text = moonrise(Position)
    lblMSet.Text = moonset(Position)
End Sub

results in the following

Page current is 1
Sunny intervals
20200827
17
06:14
Page current is 2
Cloudy
20200828
16
06:15
Page current is 3
Cloudy
20200829
15
06:17
Page current is 4
Sunny intervals

I've tried everything I can think of but getting nowhere, if it's not possible could someone please let me know and I'll think of another way of doing it, but I'm sure it is but I can't figure it out, any words of wisdom would be greatly appreciated, many thanks
 
Last edited:
Upvote 0

Colin Evans

Active Member
Licensed User
Thanks for the reply, am I better changing the variables to specific names for each layout

I presume there is no way to load the JSON data to each layout when it is shown

I found if I use the example for scrolling between layouts (Activity Touch) I can load start an activity linked to the day and then populate the layout but it just looks better with the tabstrip.

Hope that makes sense, frustrating when I've got the tabstrip working and I've got all the data I need from the JSON capture but can't then allocate to the specific days

Thanks again for the reply and I'll have a look at xCLV
 
Upvote 0

Colin Evans

Active Member
Licensed User
Hi Erel (sorry for being specific) I've attached a simple default menu system that is similar to the one I want to use in the previous example but I thought it may be easier for me to understand.

In the example I create an array and want to see if it is possible to update the lblTitle on each layout from the data created on the first activity
B4X:
Sub setTitles
    Dim i As Int
    For i = 1 To 7 - 1
        lblText(i) = "This is Page " & i
    Next
End Sub

so when I swipe across the tabstrip is it possible to update the corresponding layout's lblTitle to contain the relevant 'This is Page ?'

B4X:
Sub TabStrip1_PageSelected (Position As Int)
    Log("Page current is " & Position )
    If Position = 1 Then
        ' set the lbltitle.text on the relevant page to lbltext(position)
    End If
End Sub

Trying to understand if it is possible but can't figure it out, hope you can help, many thanks Colin
 

Attachments

  • Default Menu.zip
    499.2 KB · Views: 81
Upvote 0

klaus

Expert
Licensed User
Attached your project modified.
Your layouts are a bit strange, I modified the first ones.
Views out of the screen width anchors ?
 

Attachments

  • Default Menu1.zip
    499.2 KB · Views: 80
Upvote 0

Colin Evans

Active Member
Licensed User
Thank you very much, it's been doing my head in, I'm still not sure of the logic but I'll have a go at working the bits in I originally showed in post 1 but once again thank you greatly appreciated, and thanks for the layout, sorry about that just a rush job!
 
Upvote 0
Top