ScrollView and Groups

I need to use ScrollView to display some information that I am pulling from a SQLite database.  I would like to know if I need to have the data that is displayed in a group to be able to use scroll view.  If I do, could you please provide some sample code that I could use to insert the data into the ScrollView?

Thank you for your time and expertise.

Scrollview itself is a group. You basically need to call display.newText and insert it into the scrollView. You can then read values from your db and update display.newText.text

http://docs.coronalabs.com/api/library/display/newText.html

Depending on what you’re trying to display a widget.newTableView might be more appropriate.

Rob

Thanks for the help, things are working well, to a point.  I have the text that I am pulling from a database being inserted to the Scroll View.  But the last 5 or 10 lines of data are not showing at the bottom of the scroll.  You can see them in the “bounce” (for a lack of a proper term) when you attempt to scroll past the bottom of the scroll max.

Here is what I have inserting the data into the

for row in db:nrows(sql) do
    
    if row.data == nil then
        print(" NO DATA FOUND ")
    end

    count = count +1
    local dbText = row.data1…" - "…row.data2

    local t = display.newText(dbText, tTab, tTop + ((fSize * 1.25) + (fSize * 3.5 * count)), tWidth, 0, native.systemFont, fSize)
    t.anchorX = 0
    scrollView:insert(t)
    
end

Ok. now that we see the type of data you’re working with, I agree with Rob. This data representation probably will be served better with a tableView. I typically use a scrollView for a detail window. For a tabular list its best to go with tableView. See ListView1 or 2 samples from CL Samples and you can easily adapt your code to work with a tableView. 

In the meanwhile, if you wish the scrollView to work perhaps you need to try the following parameters in your scrollView constuct : 

bottomPadding = 50,

scrollHeight = 800  (or something that will fit your need)… 

Thanks for the help!

Thought about using tableView, but didn’t want the lines between the rows of data.

I think the lines issue is being worked on in the next widget release.

Rob

That would make life for this app a little easier.  Will keep an eye out for that.  Do you know an ETA?

Thanks ROB!!!

We generally don’t give dates because when we have in the past, something has come up that delayed it.  And with everyone taking their holiday vacation breaks…

Rob

Scrollview itself is a group. You basically need to call display.newText and insert it into the scrollView. You can then read values from your db and update display.newText.text

http://docs.coronalabs.com/api/library/display/newText.html

Depending on what you’re trying to display a widget.newTableView might be more appropriate.

Rob

Thanks for the help, things are working well, to a point.  I have the text that I am pulling from a database being inserted to the Scroll View.  But the last 5 or 10 lines of data are not showing at the bottom of the scroll.  You can see them in the “bounce” (for a lack of a proper term) when you attempt to scroll past the bottom of the scroll max.

Here is what I have inserting the data into the

for row in db:nrows(sql) do
    
    if row.data == nil then
        print(" NO DATA FOUND ")
    end

    count = count +1
    local dbText = row.data1…" - "…row.data2

    local t = display.newText(dbText, tTab, tTop + ((fSize * 1.25) + (fSize * 3.5 * count)), tWidth, 0, native.systemFont, fSize)
    t.anchorX = 0
    scrollView:insert(t)
    
end

Ok. now that we see the type of data you’re working with, I agree with Rob. This data representation probably will be served better with a tableView. I typically use a scrollView for a detail window. For a tabular list its best to go with tableView. See ListView1 or 2 samples from CL Samples and you can easily adapt your code to work with a tableView. 

In the meanwhile, if you wish the scrollView to work perhaps you need to try the following parameters in your scrollView constuct : 

bottomPadding = 50,

scrollHeight = 800  (or something that will fit your need)… 

Thanks for the help!

Thought about using tableView, but didn’t want the lines between the rows of data.

I think the lines issue is being worked on in the next widget release.

Rob

That would make life for this app a little easier.  Will keep an eye out for that.  Do you know an ETA?

Thanks ROB!!!

We generally don’t give dates because when we have in the past, something has come up that delayed it.  And with everyone taking their holiday vacation breaks…

Rob