Android Question issue with refreshing dynamically created content

RichyK68

Active Member
Licensed User
Longtime User
Hi all,

I'm using a ScrollView and dynamically adding buttons to its panel based on data from a SQL table. All good so far. The last button added is an "Add" button that calls an activity, adds one or more rows to the SQL table, and finishes and forces a refresh of the panel to show the latest additions. I know the code is running, and I've put a msgbox in there to count the views that should now be displayed in the ScrollView Panel, and the number will have increased by the relevant amount, but the panel content doesn't change, and I don't understand why. In order to see the new content, I have to finish the activity with the ScrollView and restart it, which then goes through the very same code (below) and the new content then appears. Why does the new content not show onscreen?

Here is the code that loads the content (during Activity_Create and after the activity called by buttonEditSchedule_Click finishes).

sub LoadSchedules

ScheduleScrollView.Panel.RemoveAllViews
ScheduleScrollView.Panel.LoadLayout("settings_schedules")

Dim c As Cursor = DrivingBuddy.SQL1.ExecQuery("select ID, days, starttime, endtime from schedules")
Dim loop1 As Int = 0
Dim by As Int = 20%y
For loop1 = 0 To c.RowCount - 1
c.Position = loop1
Dim b As Button
b.Initialize("buttonEditSchedule")
b.Text = c.GetString("days")

b.Tag = c.GetString("ID")

ScheduleScrollView.Panel.AddView(b, 0, by, 100%x, ButtonSize)

by = by + ButtonSize

Next

by = by + ButtonSize * 0.5

buttonAddSchedule.Initialize("buttonAddSchedule")

buttonAddSchedule.Text = "Add New Schedule ..."

ScheduleScrollView.Panel.AddView(buttonAddSchedule, 0, by, 100%x, ButtonSize)

End Sub

Can dynamically generated views only be generated during the Activity_Create method? Is the view fixed permanently fixed at that point?

Richard
 

RichyK68

Active Member
Licensed User
Longtime User
I was using the AHPageContainer and it appears when the page has been setup with the scrollview panel, the contents cannot be changed, so I got around it by simply deleting the page and re-adding it with the updated scrollview panel.
 
Upvote 0
Top