Scrollview Issue getting data to populate

markd1775

Member
Licensed User
Longtime User
I am writing an app that pulls data from a MySQL database. B4A has made that extremely easy to do.

The problem that I am having is that I cannot get a particular ScrollView to populate data on more than one panel.

I can see in the Log that there is more data there, and that i is getting incremented as it should.

Any help would be greatly appreciated.

Here is the code for response from the Database:
B4X:
Sub hc_ResponseSuccess (Response As HttpResponse, TaskId As Int)
   Dim res As String
   res = Response.GetString("UTF8")
   Log("Response from server: " &TaskId&" - "& res)
   Dim parser As JSONParser
   parser.Initialize(res)

   Select TaskId
      Case TKT_HIST
'TODO: 5.17.12 - Make this code populate the scrollview with ticket history from the DB
'add the Ticket Details to the Views
         Dim tickets As List
         Dim PanelTop, PanelHeight, PanelWidth, RowS,RowH, Col1W, Col2W As Int
         tickets = parser.NextArray 'returns a list with maps
         resCount = tickets.Size -1
   
         PanelTop = 5
         RowS = 40
   
   For i = 0 To resCount
         Dim m As Map
         m = tickets.Get(i)
         
'Fills the ScrollView with Data from the DB.      
      
      PanelHeight = 160dip
      PanelWidth = 540dip
      RowH = 40dip
      Col1W = 140dip
      Col2W = 400dip
      pnlData.Initialize("pnlData")
      lblDate.Initialize("lblDate")
      lblTime.Initialize("lblTime")
      lblUser.Initialize("lblUser")
      lblNotes.Initialize("lblNotes")
      lblLOC.Initialize("lblLOC")
      pnlData.Color = Colors.Black
      pnlBack.AddView(pnlData,0,PanelTop,PanelWidth,PanelHeight)
      pnlData.Tag = i
      pnlData.AddView(lblDate,0,PanelTop,Col1W,RowH)
      lblDate.Tag = i
      lblDate.TEXT = "Date: "& m.Get("Date")
      pnlData.AddView(lblUser,0,RowS,Col1W,RowH)
      lblUser.Tag = i
      lblUser.TEXT = "User: "& m.Get("login")
      pnlData.AddView(lblNotes,0,RowS * 2,PanelWidth,RowH * 2)
      lblNotes.Tag = i
      lblNotes.TEXT = "Notes: "& m.Get("timenotes")
      pnlData.AddView(lblTime,Col1W,PanelTop,Col2W,RowH)
      lblTime.Tag = i
      lblTime.text = "Time: "& m.Get("start")&" to "&m.Get("end")
      pnlData.AddView(lblLOC,Col1W,RowS,Col2W,RowH)
      lblLOC.Tag = i
      lblLOC.Text = "Location: "& m.Get("eventloc")
      
   Log ("i = "&i&" - "&PanelTop)
      
      PanelTop = PanelTop +PanelHeight+5
      RowS = RowS + PanelTop
   Next
         
      'Case TIME_SAVE
         'TODO: Create the result of saving time entries (show acknowledgement of save)
      '   ToastMessageShow("Time has been saved", False)
      '   txtNotes.Text = ""
      '   txtStartTime.Text = ""
      '   txtEndTime.Text = ""
         
   End Select
   ProgressDialogHide
   Response.Release
End Sub
 

klaus

Expert
Licensed User
Longtime User
What exactly is the problem?

You don't show enough code to be able to help you.
The best way would be to post your project as a zip file (IDE menu Files / Export As Zip).

Where do you define the ScrollView ?
What is pnlBack ?
pnlData.AddView(lblDate,0,PanelTop,Col1W,RowH)
should be
pnlData.AddView(lblDate,0,0,Col1W,RowH)

and
pnlData.AddView(lblTime,Col1W,PanelTop,Col2W,RowH)
should be
pnlData.AddView(lblTime,Col1W,0,Col2W,RowH)

because they are internal to pnlData.

Best regards.
 
Upvote 0

markd1775

Member
Licensed User
Longtime User
Response

Klaus,
Thank You for the response.

The problem is that I get one panel on the ScrollView. The second panel appears, but is blank with no other views or data on it.

The Scrollview is defined in the Dsigner along with pnlBack (the grey panel to create the lines between each record.

So, the values for position in Addview are relative to the parent item? That could explain the problem then.

I will try your recommendations as soon as I can get to it.
And, I will post the zip file (if still needed) then also.

-Mark
 
Upvote 0

markd1775

Member
Licensed User
Longtime User
Problem Solved

Klaus,

You were right, those variables I was using were causing the Views to not be on the panel. I was not aware that those values are relative to the child view(panel).

Lesson learned, and thank you very much!!


-Mark
 
Last edited:
Upvote 0
Top