Am porting one of my b4a app to b4i. Am attaching a scroll view initializing part ,this "initialiseView" sub is called when ever a pull refresh happens in scroll view. when refresh occur I dynamically remove current scroll panel contents and then adds all views from beginning (So that new data from my server will added to the scroll view) coding is working well but as this is not in Page_resize %x and %y values cannot be assured and after all refreshes the view goes small inside the scroll view.
Suggest a way to dynamically create this type of scroll view with contents with page_resize usage and all.
this 45%y gives wierd outputs on all refreshes as its not in Page_Resize.
Please suggest a way to structure it for b4i
Suggest a way to dynamically create this type of scroll view with contents with page_resize usage and all.
B4X:
Sub initialiseView
If dashScroll.IsInitialized = False Then
dashboard.RootPanel.Color = Colors.LightGray
dashScroll.Initialize("dashScroll",100%x,45%y*currentContests.Size-1)
dashboard.RootPanel.AddView(dashScroll,0,0,100%x,100%y)
AddRefresh(dashScroll)
downlaoder.Initialize
Log("first"&45%y&" width"&dashboard.RootPanel.Height)
Else
dashScroll.Panel.RemoveAllViews
dashScroll.ContentHeight = 45%y*currentContests.Size-1
dashScroll.ContentWidth = 100%x
Log("secon"&45%y&" width"&dashboard.RootPanel.Height)
End If
For i=0 To currentContests.Size-1
Dim p As Panel
Dim iv As ImageView
Dim heading As Label
Dim description As Label
Dim photoNum As Label
Dim photoNumIcon As ImageView
Dim headingShadow As ImageView
Dim uploadPicIcon As ImageView
Dim m As Map
m=currentContests.Get(i)
p.Initialize("panel")
heading.Initialize("")
description.Initialize("")
photoNum.Initialize("")
photoNumIcon.Initialize("")
headingShadow.Initialize("")
uploadPicIcon.Initialize("uploadPicIcon")
p.Color=Colors.White
iv.Initialize("")
Main.downloadLinks.Put(iv,m.Get("cover_photo"))
heading.Text = m.Get("contest_name")
heading.Text = heading.Text.ToUpperCase
heading.TextColor=Colors.White
description.Text = m.Get("description")
description.TextColor=Colors.White
photoNum.Text = m.Get("photo_count")
photoNum.TextColor=Colors.White
photoNumIcon.Bitmap = LoadBitmap(File.DirAssets,"image_holder.png")
headingShadow.Bitmap = LoadBitmap(File.DirAssets,"shadow.png")
uploadPicIcon.Bitmap = LoadBitmap(File.DirAssets,"picture-add.png")
p.AddView(iv,0,0,100%x,45%y)
p.AddView(headingShadow,0,33%y,100%x,12%y)
p.AddView(heading,2%x,34%y,100%x,10%y)
p.AddView(description,2%x,40%y,100%x,4%y)
p.AddView(photoNum,10%x,3%y,10%x,5%y)
p.AddView(photoNumIcon,2%x,2%y,8%x,8%x)
p.AddView(uploadPicIcon,85%x,2%y,13%x,11%x)
uploadPicIcon.Tag=i
p.Tag=i
dashScroll.Panel.AddView(p,0,i*45%y,100%x,45%y)
Next
downlaoder.Download(Main.downloadLinks)
End Sub
B4X:
Log("first"&45%y&" width"&dashboard.RootPanel.Height)
this 45%y gives wierd outputs on all refreshes as its not in Page_Resize.
Please suggest a way to structure it for b4i