I've got the core of my application working but am having some issues with the display of data when the device switches orientation (rotates).
From what I've read here this is my understanding of the execution loop:
Program starts, Activity_Create runs (The first time it runs a Boolean variable FirstTime is true).
If the orientation of the device changes, Activity_Pause gets called, then Activity_Create (with FirstTime = false), then Activity_Resume.
If the device display times out and switches off (the display, not the device) the execution is Activity_Pause, then when it wakes up again Activity_Create and Activity_Resume.
Is that right?
I have a single activity application. In this Activity I load my main layout which has a tabhost on it, then I tabHost.AddTab() 4 tabs each with their own layout.
On 3 of these tabs I have a listview (actually one is a plain list view and the other 2 are listviews but using the SearchView example, although that shouldn't make a difference).
Based on the above logic I am trying to display the data in my list views when the orientation changes or the device goes into power save. However, the list on the first tab displays nothing in it when the application first starts, but displays the list when the orientation changes.
The other lists display when the application first starts but not when the orientation changes. Also, the correct tab does not get displayed when the orientation changes.
So I've got my logic wrong somewhere
These are the procedures that build the lists:
Any insights?
From what I've read here this is my understanding of the execution loop:
Program starts, Activity_Create runs (The first time it runs a Boolean variable FirstTime is true).
If the orientation of the device changes, Activity_Pause gets called, then Activity_Create (with FirstTime = false), then Activity_Resume.
If the device display times out and switches off (the display, not the device) the execution is Activity_Pause, then when it wakes up again Activity_Create and Activity_Resume.
Is that right?
I have a single activity application. In this Activity I load my main layout which has a tabhost on it, then I tabHost.AddTab() 4 tabs each with their own layout.
On 3 of these tabs I have a listview (actually one is a plain list view and the other 2 are listviews but using the SearchView example, although that shouldn't make a difference).
Based on the above logic I am trying to display the data in my list views when the orientation changes or the device goes into power save. However, the list on the first tab displays nothing in it when the application first starts, but displays the list when the orientation changes.
The other lists display when the application first starts but not when the orientation changes. Also, the correct tab does not get displayed when the orientation changes.
So I've got my logic wrong somewhere
B4X:
Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
Else
CurrentPage = tbhMain.CurrentTab
End If
End Sub
Sub Activity_Resume
SetRouteList 'listview on first tab
BuildLoadList 'listview on 2nd tab
BuildDeliveryList 'listview on 3rd tab
tbhMain.CurrentTab = CurrentPage
End Sub
These are the procedures that build the lists:
B4X:
Sub SetRouteList
Dim Routes As List
Routes = DBUtils.ExecuteMemoryTable(SQLLite, "SELECT rte_name FROM Routes", Null, 0)
For i = 0 To Routes.Size - 1
Dim route() As String
route = Routes.Get(i)
lvwRoutes.AddSingleLine(route(0))
Next
End Sub
Sub BuildLoadList As List
Dim AWBs As List
AWBs = DBUtils.ExecuteMemoryTable(SQLLite, "SELECT awb_number, cus_company, del_scancode FROM RunSheetDetails LEFT JOIN DeliveryHistory ON rnd_pk = del_rndfk AND del_scancode = 1 ORDER BY cus_company", Null, 0)
Return AWBs
End Sub
Sub BuildDeliveryList As List
Dim x As List
x = DBUtils.ExecuteMemoryTable(SQLLite, "SELECT DeliveryHistory.* FROM DeliveryHistory",Null,0)
Dim Deliveries As List
Deliveries = DBUtils.ExecuteMemoryTable(SQLLite, _
"SELECT awb_number, cus_company, DeliveryHistory.del_scancode, " _
& "DeliveryHistory.del_delivered " _
& ", cus_number " _
& "FROM DeliveryHistory " _
& "INNER JOIN (SELECT MAX(del_time) AS Latest, del_rndfk FROM DeliveryHistory GROUP BY del_rndfk) b " _
& "ON DeliveryHistory.del_rndfk = b.del_rndfk AND DeliveryHistory.del_time = b.Latest " _
& "INNER JOIN RunSheetDetails ON DeliveryHistory.del_rndfk = rnd_pk " _
& "ORDER BY DeliveryHistory.del_delivered, cus_company, awb_number " _
, Null, 0)
Return Deliveries
End Sub
Any insights?