Android Question ScrollView help please

Scotter

Active Member
Licensed User
I've looked at the "ScrollView.b4a" project but it doesn't answer my questions.
Please look at the attached image.
I'm pulling rows from a database.
Each row has a few fields, including Name, ShortDescription, CaptionDate, and Date. <-- I'll be using "row" to describe all this data from now on.
(1) Am I doing the right thing by putting a bunch of labels in Panel1, with Panel1 as their parent?
(2) How does ScrollView1 know Panel1 is inside it? I notice when I click properties of Panel1 in the designer, it doesn't allow ScrollView1 to be set as its parent.
(3) Do I even need Panel1? Does ScrollView1.Panel.Addview(...) refer to Panel1 or a sort of built in Panel that is part of ScrollView1?
(4) Once I get all this set up in the designer, what code do I need to use to add a row of data so that the user can then scroll through rows? I see it is best to use ScrollView1.Panel.Addview(...) but how exactly would I do that in my loop that is reading from the database, as far as filling those labels with text? How do those labels become like an array?
Thanks for any help you can give me!
 

Attachments

  • scrollViewQuestion.jpg
    scrollViewQuestion.jpg
    210.8 KB · Views: 210

GGSoft

Member
Licensed User
Longtime User
Hi!

I had a similar situation some time ago. This is what I did:

1.- Put a scrollView in the designer

2.- At run-time:

2.1 For each record I get from the database:

2.1.1 Create a panel (dim or private)
2.1.2 Create all the views I need (dim or private)
2.1.3 Put the data from the record into the views
2.1.4 Add the views to the panel
2.1.5 Add the panel to the scroll view

2.2 Assign scrollView.panel.height equal to the height occupied by the panels

Hope this help.
 
Upvote 0

Scotter

Active Member
Licensed User
Hi!
I had a similar situation some time ago. This is what I did:
1.- Put a scrollView in the designer
2.- At run-time:
2.1 For each record I get from the database:
2.1.1 Create a panel (dim or private)
2.1.2 Create all the views I need (dim or private)
2.1.3 Put the data from the record into the views
2.1.4 Add the views to the panel
2.1.5 Add the panel to the scroll view
2.2 Assign scrollView.panel.height equal to the height occupied by the panels
Hope this help.
Thank you! I'll play with doing it that way tomorrow.
I appreciate you taking the time to write this out in such an organized and easy-to-follow way!
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Just a comment to post #2.
It is not necessary to use a Panel for each row. You can add the Labels directly onto the ScrollView.Panel.

For your problem, showing data from a database, i see three possibilities.
- Use the Table class, you can directly load data from a SQLite database and fill the table.
- Use a CustomListView.
- Or do it on your own with a ScrollView. In this case I'd suggest you to use ScrollView2D, which allows to scroll in both directions, instead of a standard ScrollView.
 
Upvote 0
Top