I have a B4XPages project and am using B4A v11.20 on it. The app runs Ok on a phone except for one point. The app has a DetailsPage called by the MainPage on clicking its Start button ('defined' in the page's main.bal file. The DetailsPage has an imageview ('defined' in its details.bal file) containing a jpg photo. This photo varies according to a variable StepNumber defined in the DetailsPage and set to 1 on page creation: that works Ok. There are Previous & Next buttons defined in the details.bal. The idea is that according to StepNumber, the Enable & Visible properties should be set e.g. if the StepNumber is 1 only the Next button should be enabled & visible, if the StepNumber is in the range 2-5 both buttons should be enabled & visible, if the StepNumber is 6 only the Previous button should be enabled & visible.
Here is the relevant code from the DetailsPage:
I've attached a zip of the project: the whole code is approx 120 lines so I didn't think that it was worth making a Test project from it!
PS the Sub ReloadViews uses StepNumber to set the photo in DetailsPages' imageview.
Here is the relevant code from the DetailsPage:
B4X:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private lbl As B4XView
Private iv As B4XView
Private btnPrevious As B4XView
Private btnNext As B4XView
Private StepNumber As Int
End Sub
'You can add more parameters here.
Public Sub Initialize As Object
Return Me
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
'load the layout to Root
Root.LoadLayout("Details")
StepNumber = 1
End Sub
Private Sub B4XPage_Appear
If StepNumber < 2 Then
btnPrevious.Enabled = False
btnPrevious.Visible = False
Else
btnPrevious.Enabled = True
btnPrevious.Visible = True
End If
If StepNumber > 5 Then
btnNext.Enabled = False
btnNext.Visible = False
Else
btnNext.Enabled = True
btnNext.Visible = True
End If
ReloadViews
End Sub
Private Sub btnPrevious_Click
If StepNumber > 1 Then
StepNumber = StepNumber - 1
ReloadViews
End If
End Sub
Private Sub btnNext_Click
If StepNumber < 6 Then
StepNumber = StepNumber + 1
ReloadViews
End If
End Sub
I've attached a zip of the project: the whole code is approx 120 lines so I didn't think that it was worth making a Test project from it!
PS the Sub ReloadViews uses StepNumber to set the photo in DetailsPages' imageview.