Android Question [ANSWERED] ScrollView "ghost" item displayed at end after delete an item.

Lee Gillie CCP

Active Member
Licensed User
Longtime User
In Activity A I display a ScrollView of orders. User selects an order, which starts item detail activity. From here the item is DELETED, and item detail activity is FINISHED. When Activity A resumes I call my refresh routine. On the screen we see all the correct orders displayed and refresh, reflecting the removal of an order. But at the BOTTOM of the scroll view there is STILL a ghost image of the order that WAS previously display at the end. I don't understand why when Activity A resumes, and remakes the scroll view, that the visual of the old "last item in list" is still seen. Note: I can not click this ghost item to go into order edit, so I know it is merely an image.

Can't seem to figure out how to properly reset the scroll view before reloading it with a refreshed item list?

B4X:
Sub Activity_Resume
    Activity.LoadLayout("OrderList")
    RefreshOrderList
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub Activity_Create(FirstTime As Boolean)
End Sub


Sub RefreshOrderList
    Dim cmd As String
    Dim crs As Cursor
    Dim row As Int
    Dim pnl As Panel
    Dim ItemCount As Int
 
    Dim Truck As String

    Truck = "Unknown"
 
    bmDn.Initialize(LoadBitmap(File.DirAssets,"OrderDown.png"))
    bmUp.Initialize(LoadBitmap(File.DirAssets,"OrderUp.png"))
    bmEd.Initialize(LoadBitmap(File.DirAssets,"EditInformation.png"))

    Select Case Main.OrderListMode
    Case Globals.DeliveredOrders
        Activity.Title = "Eljay Delivery - Delivered Orders"
        cmd = "SELECT * FROM OpenOrderHeader WHERE Status = 'D' ORDER BY PresentationOrder, ShipToAddress1, OrderNumber"
    Case Globals.UndeliveredOrders
        Activity.Title = "Eljay Delivery - Undelivered Orders"
        cmd = "SELECT * FROM OpenOrderHeader WHERE Status <> 'D' ORDER BY PresentationOrder, ShipToAddress1, OrderNumber"
    Case Else
        Activity.Finish
        Return
    End Select

    ProgressDialogShow("Loading invoices for display." & CRLF & "Please wait....")
 
    svItems.Invalidate
    dragOrderManager.Initialize(Me,"dragOrderManager",svItems)
 
    crs = Globals.Delivery.ExecQuery( cmd )

 
    Dim start As Long = DateTime.Now
 
    Top = Gap
    Dim statusText As String
 
    ProgressDialogShow("Loading " & crs.RowCount & " invoices for display." & CRLF & "Please wait....")
 
    ItemCount = crs.RowCount
    For row = 0 To crs.RowCount-1
        Log("Retrieving row " & row)
        statusText = "Loading " & (row+1) & " of " & crs.RowCount & "invoices, please wait..."
        lbStatus.Text = statusText

        DoEvents
        crs.Position = row

        Dim hdr As OpenOrderHeader

        hdr.Initialize
        hdr.FromCursor(crs)
        hdr.PresentationOrder = dragOrderManager.svScrollView.Panel.NumberOfViews
        pnl = CreatePanelForOrderHeader( hdr )
        dragOrderManager.AddItem(pnl)
     
        Truck = hdr.SalesmanName

    Next
 
    crs.Close
 
    Dim secs As Float = ( DateTime.Now - start ) / 1000
 
    lbStatus.Text = ItemCount & " orders for """ & Truck & """"

    ProgressDialogHide
 
End Sub
 

klaus

Expert
Licensed User
Longtime User
First point, you should not load layouts in Activity_Resume but in Activity_Create!
Unfortunately you don't show wnough code!
What is svItems?
Is it s ScrollView?
It seems that you are using a ScrollView svScrollView, where do you adjust the internal panel height?
 
Upvote 0

Lee Gillie CCP

Active Member
Licensed User
Longtime User
I moved the load layout, and in my drag order manager added code to force recomputing panel height. All is well now!

Seems I get away from B4A for a few months and I might as well be learning again when I return. Windows is where I live, and Android is a bit different.

Klaus, thank you so much for your reply, it seemed to have triggered it for me, and the problem is fixed.

Best regards - Lee
 
Upvote 0
Top