iOS Question How to dynamically create controls and position them in a scrollview

davepamn

Active Member
Licensed User
Longtime User
I need to dynamically create a text box, label, and picker object in a series.
 
Last edited:

davepamn

Active Member
Licensed User
Longtime User
Or should I use a Webview with an html input form to gather my information and use a post method to submit it?
 
Upvote 0

Bruno.im

Member
Licensed User
Longtime User
I need to dynamically create a text box, label, and picker object in a series.

Dim LB(5) As Label
Dim x As Int
x= 20
For I= 0 To 4
Lb(I).Initialize("Lb")
Lb(I).Text= "Label " & (I+1)
ScrollView1.Panel.AddView(Lb(I),10, x,100,40)
x=x+40
Next

This should create 5 Labels on a scrollview
 
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
B4X:
Dim y As Int

    y=20

    For i = 0 To oItems.Size - 1
        oRowMap=oItems.Get(i)
        sTestId=oRowMap.Get("sTestId")
        sTestIdValue=oRowMap.Get("sTestIdValue")
 
        Dim oLB2 As Label
        oLB2.Initialize("2lb"&i)
        oLB2.Text=sTestIdValue

        ScrollViewInput.Panel.AddView(oLB2,10dip,y,200dip,100dip)

        y=y+40

    Next

I don't see my complete list in the scrollviewinput. what determines the size of the scrollview.

I have about 70 items to display. I only see a partial list, but my log shows all the items arrived in the httpjob handler

Am I responsible to calculate the page size
 
Last edited:
Upvote 0

Bruno.im

Member
Licensed User
Longtime User
Your ScrollView1.ContentHeight is not big enough. There is a difference between Height of the Scrollview and ContentHeight.
Try
Scrollview1.Height=100%y
ScrollView1.ContentHeight=200%y
 
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
that worked however. I was surprised that there is no indicator suggesting the control is scrollable. It looks truncated rather than scrollable, at first.
 
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
I get a narrow band that is scrollable.

How do I control the width of the scrollable window?
B4X:
    ScrollViewInput.Height=100%y

    ScrollViewInput.ContentHeight=400%y

    ScrollViewInput.ContentWidth=100%x

    ScrollViewInput.Width=100%x
The width parameters don't seem to be working.
I added the iPad width and length variants in designer
 
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
B4X:
Sub HandleTestIdValues(Job As HttpJob)

If Job.Success = False Then
        hd.ToastMessageShow("Error downloading List.", True)
        hd.ProgressDialogHide
        Return
    End If

    Try

    Dim Text As String=StripTags(Job.GetString)
    Dim p AsJSONParser

    p.Initialize(Text)
    Dim oItems As List

    oItems =p.NextArray
    Dim sTestId As String
    Dim sTestIdValue As String
    Dim sBuffer As String
    Dim iRowOffset As Int
    iRowOffset=20

    ScrollViewInput.Height=100%y
    ScrollViewInput.ContentHeight=400%y
    ScrollViewInput.ContentWidth=100%x
    ScrollViewInput.Width=100%x

    For i = 0 To oItems.Size - 1
       oRowMap=oItems.Get(i)
        sTestId=oRowMap.Get("sTestId")
        sTestIdValue=oRowMap.Get("sTestIdValue")
        sBuffer=sBuffer & " " & sTestId

        Dim oLB2 As Label
        oLB2.Initialize("2lb"&i)
        oLB2.Text=sTestIdValue
        ScrollViewInput.Panel.AddView(oLB2,10dip,iRowOffset,90%x,100dip)
       iRowOffset=iRowOffset+40
    Next
    Catch
            oError.ShowLastException("Error Loading testid values")
    EndTry
End Sub

I am getting a narrow scrollable window

I want a scrollable window that uses the width of the device to display and have 4 times the length of the device in content.
 
Upvote 0

davepamn

Active Member
Licensed User
Longtime User
It worked when I used Page1_Resize
but if I used Page3_Resize the scrollview was frozen

B4X:
Private Sub Page1_Resize(Width As Int, Height As Int)

    ScrollViewInput.Height=100%y
    ScrollViewInput.ContentHeight=400%y
    ScrollViewInput.ContentWidth=100%x
    ScrollViewInput.Width=100%x

End Sub
 
Last edited:
Upvote 0
Top