Android Question Saving/Displaying State of SearchView

Frank Cazabon

Member
Licensed User
Longtime User
Hi,

I have an application with a single Activity. The main view has a tabhost with 4 tabs. On 2 of these tabs I have a searchview showing different data. The searchviews are configured to automatically show all items in the list when nothing has been typed in the edit box.

When I switch orientation, the lists go blank.

The data is still available as I can see it when I start typing values in the edit box.

How do I get it to re-display the list that was being displayed prior to the orientation switch?

Some code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    If StateManager.RestoreState(Activity, "Main", 60) = False Then
        'set the default values
    End If
   
' these are the 2 searchviews
    svwAWB.Initialize(Me, "svwAWB")
    svwDelivery.Initialize(Me, "svwDelivery")

    Activity.LoadLayout("MainMenu")

    If ConnectedToLAN.weconnected = "YES" Then
        tbhMain.AddTab("Select Route","SelectRoute")
    End If
   
    tbhMain.AddTab("Load","Load")
    tbhMain.AddTab("Deliver","Deliver")
    tbhMain.AddTab("Upload","Upload")

    If FirstTime Then
   
        Dim DeliveryAWBs As List
        DeliveryAWBs = BuildDeliveryList
        DeliveryIndex = svwDelivery.SetItems(DeliveryAWBs)

        Dim AWBs As List
        AWBs = BuildLoadList
        AWBIndex = svwAWB.SetItems(AWBs)
    Else
        svwAWB.SetIndex(AWBIndex)
        svwDelivery.SetIndex(DeliveryIndex)
    End If
   
    svwAWB.AddToParent(pnlLoad, 0, 0, 100%x, 100%y)
    pnlLoadDetail.Visible = False

    svwDelivery.AddToParent(pnlDeliver, 0, 0, 100%x, 100%y)
    pnlDeliverDetail.Visible = False
   
    StateManager.RestoreState(Activity, "Main", 60)

End Sub
 
Top