i guess a lot more code (not all code is visible in your example) but NOT several Pages... (even for a noob like me)
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private CustomListView1 As CustomListView
Private vpW, vpH As Float 'ignore
Private dayNames As List = Array As String("Sunday","Monday","Tuesday","Wednesday","Thurdsay","Friday","Saturday")
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
vpW = MainForm.RootPane.Width
vpH = MainForm.RootPane.Height
For i = 1 To 100
Dim p As B4XView = xui.CreatePanel("")
p.SetLayoutAnimated(0, 0, 0, MainForm.RootPane.Width, 200dip)
p.LoadLayout("item")
CustomListView1.Add(p, "")
Next
updateButtonText 'call at start for all ide's
End Sub
Private Sub MainForm_Resize (Width As Double, Height As Double)
updateButtonText
End Sub
Private Sub updateButtonText
For i = 0 To CustomListView1.Size-1
Dim p As B4XView = CustomListView1.GetPanel(i)
For Each n As Node In p.GetAllViewsRecursive
If n Is Button Then
Dim b As Button = n
b.Text = getTextAccordingToSize(b.Tag.As(Int), b.Width)
End If
Next
Next
End Sub
Private Sub getTextAccordingToSize(day As Int, size As Float) As String
If size < vpW*0.1 Then
Return dayNames.Get(day-1).As(String).SubString2(0,1)
else if size < vpW*0.15 Then
Return dayNames.Get(day-1).As(String).SubString2(0,2)
else if size < vpW*0.2 Then
Return dayNames.Get(day-1).As(String).SubString2(0,3)
Else
Return dayNames.Get(day-1)
End If
End Sub
I am facing an issue with my POS system where I need to hide the logo in the print preview based on user's change settings and need to readjust the content panel's top position when the logo is hidden. If I understand correctly what this feature is all about, it will be useful or make things easier for me. I want to try it out when it is available.
One thing I don't understand here is, inside the Designer Script, the code accepts 3 function arguments while the B4X code has only 1 function parameter.
I am facing an issue with my POS system where I need to hide the logo in the print preview based on user's change settings and need to readjust the content panel's top position when the logo is hidden. If I understand correctly what this feature is all about, it will be useful or make things easier for me. I want to try it out when it is available.
One thing I don't understand here is, inside the Designer Script, the code accepts 3 function arguments while the B4X code has only 1 function parameter.
Good catch. The signature of "designer callable" subs is a single DesignerArgs parameter. This object holds all kinds of important details including a list with the parameters.
As I wrote the main advantage of the new feature is that all or most of the layout related implementation is encapsulated in the layout file. Think of a large project with many layouts that are added and removed. As the project grows it becomes more and more complicated to manage the state. Especially when the same layout can be loaded in different places.
Anyway there is no reason to argue about it. This is an optional tool, which I'm sure that it will be useful in many cases and like any tool, it is the developer who chooses what to use and what not to use.
i am sorry, it was not my intention to argue i just wanted to understand how and when this feature could be useful. now everything is clear. thank you for your great work and effort Erel ?
The demo is like creating responsive website with Bootstrap but in B4X apps instead. Really good for creating cross platform app with different screen size. I think my numpad layout designer script for my POS system can be more simplified. I don’t need to assign the button size and left and top position for each button with 3 lines of code but can accomplish with 1 line of code only.