With this code, I display Layout "Menu" with the BtnMenu button, then from Layout Menu I display Layout "Listing" with the BtnListing button.
If I return to the Layout "Menu" using the back button, then I return to the Layout "Listing" with the BtnListing button it bugs. I think there is an initializing problem but I don't see where.
Can you help me?
Thank you
If I return to the Layout "Menu" using the back button, then I return to the Layout "Listing" with the BtnListing button it bugs. I think there is an initializing problem but I don't see where.
Can you help me?
Thank you
B4X:
'Code module
#Region Project Attributes
#ApplicationLabel: B4i Example
#Version: 1.0.0
'Orientation possible values: Portrait, LandscapeLeft, LandscapeRight and PortraitUpsideDown
#iPhoneOrientations: Portrait, LandscapeLeft, LandscapeRight
#iPadOrientations: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown
#End Region
Sub Process_Globals
Public NavControl As NavigationController
Private Page1, Cherche, Listing, Menu As Page
Private LblCherche, LblBJ, LblLayoutMain As Label
Private BtnCherche As Button
Private segmentedcontrol1 As SegmentedControl
Dim ClvListing As CustomListView
Private hd As HUD
Private Downloader As ImageDownloader
Dim LISTING_LIST As String
End Sub
Private Sub Application_Start (Nav As NavigationController)
NavControl = Nav
Page1.Initialize("Page1")
Page1.Title = "SittingBreak"
Page1.RootPanel.Color = Colors.Blue
NavControl.ShowPage(Page1)
Page1.RootPanel.LoadLayout("Main")
Cherche.Initialize("Cherche")
Cherche.RootPanel.LoadLayout("Cherche")
Menu.Initialize("Menu")
Menu.RootPanel.LoadLayout("Menu")
End Sub
Sub BtnCherche_Click
Cherche.Title = "Cherche"
LblBJ.Text = "Bonjour"
segmentedcontrol1.BringToFront
NavControl.ShowPage(Cherche)
End Sub
Sub BtnListing_Click
Listing.Initialize("Listing")
Listing.RootPanel.LoadLayout("Listing")
Listing.RootPanel.Color = Colors.ARGB(255,109,237,199)'(255,255,0,0)
Listing.Title = "Listing"
ClvListing.Initialize(Me, "clvListing", 100%x)
Listing.RootPanel.AddView(ClvListing.AsView, 0, 0, 100%x, 50%y)
ExtraitListePardistance
NavControl.ShowPage(Listing)
End Sub
Sub BtnMenu_Click
NavControl.ShowPage(Menu)
End Sub
Sub CreateListItem3(Text1 As String, Text2 As String, Text3 As String, ImgPath As String, Width As Int, Height As Int) As Panel
'Routine pour placer 2 labels dans l'item de la customListView
Dim P As Panel
P.Initialize("")
P.Color = Colors.White
Dim lbl1, lbl2, lbl3 As Label
lbl1.Initialize("lbl1")
lbl1.TextAlignment = lbl1.ALIGNMENT_LEFT
lbl1.Text = Text1
lbl1.Font = Font.CreateNew(22)
lbl2.Initialize("lbl2")
lbl2.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl2.Multiline= True
lbl2.Text = Text2
lbl2.Font = Font.CreateNew(16)
lbl3.Initialize("lbl3")
lbl3.TextAlignment = lbl2.ALIGNMENT_LEFT
lbl3.Multiline= True
lbl3.Text = Text3
lbl3.Font = Font.CreateNew(18)
Dim ImgVignette As ImageView
ImgVignette.Initialize("ImgVignette")
Dim Repertoire = File.DirAssets As String
P.AddView(ImgVignette, 10dip, 5dip, 18%x, 18%x )
P.AddView(lbl1, 10dip + 20%x, 0dip, 75%x, Height/2-5dip )
P.AddView(lbl2, 10dip + 20%x, lbl1.Height, 75%x, Height/2)
P.AddView(lbl3, 10dip + 20%x, (lbl1.Height +lbl2.Height)-5dip, 75%x, Height/2)
Return P
End Sub
Sub JobDone (Job As HttpJob)
Log("JobName = " & Job.JobName & ", Success = " & Job.Success)
If Job.Success = True Then
Select Job.JobName
'XXXXXXXXX LISTING XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Case LISTING_LIST
'Downloader.Initialize
Dim RES, RES2 As String
RES = Job.GetString
Dim parser As JSONParser
parser.Initialize(RES)
Dim Affiche_list As List
Affiche_list = parser.NextArray 'returns a list with maps
For i = 0 To Affiche_list.Size - 1
Dim sb As StringBuilder
Dim M As Map
M = Affiche_list.Get(i)
Dim Civilite, Prenom, Ville, Zip As String
'----------------------------------------------------------------------------------
Civilite = M.Get("civilite")
Prenom = M.Get("prenom")
Ville = M.Get("ville")
Zip = M.Get("zip")
ClvListing.Add(CreateListItem3(Civilite, Prenom, Ville, Zip,ClvListing.AsView.Width, 55dip), 70dip, M)
Next
End Select
Else
Log("Error: " & Job.ErrorMessage)
hd.ToastMessageShow("Error: " & Job.ErrorMessage, True)
End If
Job.Release
End Sub
Sub ExtraitListePardistance
ExecuteRemoteQuery("SELECT ID, civilite, prenom, ville, zip FROM kindasitters ",LISTING_LIST)
End Sub
Sub ExecuteRemoteQuery(Query As String, JobName As String)
Dim job As HttpJob
job.Initialize(JobName, Me)
job.PostString("http://www.xxxxxxxx.com/xxxxxxxx/connection.php", Query)'
End Sub
Sub SegmentedControl1_IndexChanged (Index As Int)
Select Index
Case 0
Cherche.RootPanel.Color = Colors.Green
Cherche.Title = "Cherche"
LblBJ.Text = "Bonjour"
segmentedcontrol1.BringToFront
NavControl.ShowPage(Cherche)
Case 1
Cherche.RootPanel.Color = Colors.Yellow
Cherche.Title = "Cherche"
LblBJ.Text = "Bonsoir"
segmentedcontrol1.BringToFront
NavControl.ShowPage(Cherche)
End Select
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
End Sub
Private Sub Application_Background
End Sub