Designer script issue/enhancement

jfranz

Member
Licensed User
Longtime User
I have a issue with the DesignerScript and RerunDesignerScript that I can't seem to come up with a good work around. Maybe someone can help me.

I have created a project that uses the AHPViewPager for main navigation. The pager contains 8 to 10 panels and 4 or 5 of these have the exact same layout. What I do is loop and create a panel that will do a LoadLayout based on the counter. The panel's tag keeps an info type that helps keep track of the data contained in the panel.

It will then set the views (controls in my world in case I slip back and use that term) to their expected values using something similar to the following. It isn't the best but since there is no way to iterate through the controls (see I slipped) and get their names; I have to deal with control hierarchy. This is very ugly and would benefit from a name and a method to get a control by its parent and name. Typing this up I thought maybe using the Tag instead of Name. Enhancement in designer to auto set Tag to name?

parent = PageContainer.GetPageObject(pageNum)
pnl = parent.GetView(0)
dim vw as ImageView
vw = pnl.GetGet(3)
... code to load a bitmap into bmp etc
vw.Bitmap = bmp

Lots of work instead of something like
vw = FindView(parent, "Panel1.IVAvatar")

Sorry, I went off on a tagent. What I am finding is that since I created the pager panels and used LoadLayout the pager panels are too tall and thus the lower portion of the panels are not visible. If I do a RerunDesignerScript only the last known panel with the specified name gets adjusted. What I need is to tell RerunDesignerScript which parent panel to apply the changes to. Maybe even have the LoadLayout give back a unique ID that keeps track of the parent panel and script and then call RerunDesignerScript with an ID instead of the name again.

This might be a partial issue with the pager library but I know the layout/designer isn't as smart as it might be.

Thanks for any info/comments on this.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
What I am finding is that since I created the pager panels and used LoadLayout the pager panels are too tall and thus the lower portion of the panels are not visible. If I do a RerunDesignerScript only the last known panel with the specified name gets adjusted.
Why do you need to call RerunDesignerScript? The script will be executed when you call LoadLayout. Your script should adjust the layout to fit the panel size.
 
Upvote 0

jfranz

Member
Licensed User
Longtime User
Thanks Erel for trying to help.

I have the following sub that sets things up. I am loading/scraping webpages to display the info and that happens as HttpJob calls the JobDone method.

In this code Panel0 seems ok but everything else is 37dips too tall. The last 3 lines help get around the issue partially; only the last Info panel is resized since that was the last panel loaded using the LoadLayout.

Like I mentioned earlier maybe this is a AHViewPager issue but seems more like a LoadLayout issue to me.


Sub PagerSetup()
Dim title As String
mPagerContainer.Initialize
Dim pnlName As String

For x = 0 To 7
Dim pi As PanelInfo
pi.Initialize

Dim pnl As Panel
pnl.Initialize("")

title = gMenuNames(x)

Select x
Case 0
pnlName = "Panel0"
wvForecast.Initialize(title)
pnl.AddView(wvForecast, 0, 0, FILL_PARENT, FILL_PARENT)

case 6
pnlName = "Webcam"
pnl.LoadLayout("Webcam")

Case 7
pnlName = "Maint"
pnl.LoadLayout("Maint")

Case Else
pnlName = "PnlInfo" & x
pnl.LoadLayout("Info")

End Select
pi.PanelName = title
pnl.Tag = pi
mPagerContainer.AddPage(pnl, title)

Next

'Create the Pager view.
mPager.Initialize(mPagerContainer, "mPager")
'show the tabs page indicator
mPagerTabs.Initialize(mPager)
mPagerTabs.LineHeight = 5dip
mPagerTabs.UpperCaseTitle = False
mPagerTabs.LineColorCenter = Colors.Blue
Activity.AddView(mPagerTabs, 0, 0, FILL_PARENT, WRAP_CONTENT)

'We add a line below the tab page indicator because it looks good
Dim col As ColorDrawable
col.Initialize(mPagerTabs.LineColorCenter, 0)
mPagerLine.Initialize("")
mPagerLine.Background=col
Activity.AddView(mPagerLine, 0, 35dip, Activity.Width, 2dip)

'add the pager to the activity
Activity.AddView(mPager, 0, 35dip + 2dip, Activity.Width, Activity.Height-35dip-2dip)

' Ensure all panels have correct height.
Activity.RerunDesignerScript("Maint", Activity.Width, Activity.Height - 37dip)
Activity.RerunDesignerScript("Webcam", Activity.Width, Activity.Height - 37dip)
Activity.RerunDesignerScript("Info", Activity.Width, Activity.Height - 37dip)
end sub
 
Upvote 0
Top