Android Question CLVSwipe and lazy loading clv

Schakalaka

Active Member
Licensed User
Longtime User
Hello,
no way to make it working:
my code:

B4X:
Type dtransazione (panel As String, imgg As String ,txtDescrizione As String,  txtconto As String, txtData As String, txtcategoria As String, txtbeneficiario As String, txtprice As String)

data are from sql db
B4X:
    If result.RowCount > 0 Then
        
    Do While result.NextRow
            Dim CardItem As dtransazione
            CardItem.txtData = DateTime.Date(result.GetString("movData"))
            CardItem.txtconto = result.GetString("movConto")
            CardItem.txtcategoria = result.GetString("movCategoria")
            CardItem.txtDescrizione = result.GetString("movDescrizione")
            CardItem.txtbeneficiario = result.GetString("movPersona")
            CardItem.txtprice = result.GetString("movImporto")
            
            If CardItem.txtprice >= 0 Then
                img = "increaseappicon.png"
            Else
                img = "moneydownicon.png"
            End If
            
            CardItem.imgg = img
            
            Dim p As B4XView = xui.CreatePanel("") ' Crea un pannello principale
            p.SetLayoutAnimated(0, 0, 0, CvlMovTot.AsView.Width, 145dip)

             CvlMovTot.Add(p,CardItem) ORIGINAL WORKING

            CvlMovTot.Add(createitem446(CardItem),Swipe.CreateItemValue(CardItem, Array("close operation"))) 
            
        Loop
    
    Else
        CvlMovTot.AddTextItem("No Transactions yet",0)
        Log($"Nessun elemento nella tabella $tableName"$)
    End If

    result.Close

B4X:
Private Sub CvlMovTot_VisibleRangeChanged (FirstIndex As Int, LastIndex As Int)

    Dim ExtraSize As Int = 25 'List size
    For i = Max(0, FirstIndex - ExtraSize) To Min(LastIndex + ExtraSize, CvlMovTot.Size - 1)
        Dim Pnl As B4XView = CvlMovTot.GetPanel(i)
        If i > FirstIndex - ExtraSize And i < LastIndex + ExtraSize Then
            If Pnl.NumberOfViews = 0 Then 'Add each item/layout to the list/main layout
                Dim tdettagli As dtransazione = CvlMovTot.GetValue(i) <--[U]HERE CRASH java.lang.RuntimeException: Field: txtDescrizione not found in: android.finanze.sql.clvswipe$_swipeitem[/U]
                Pnl.LoadLayout("clvMovTot")
                lblName.Text = tdettagli.txtDescrizione
                lblImporto.Text = tdettagli.txtprice & " €"
                lblData.Text = tdettagli.txtData
                lblTipo.Text = tdettagli.txtcategoria
                lblconto.Text = tdettagli.txtconto
                lblPerson.Text = tdettagli.txtbeneficiario
                AjustaImageView(imgMov,tdettagli.imgg)

                If tdettagli.txtcategoria <> "Generale" Then
                    lblPerson.Visible = True
            
                Else
                    lblPerson.Visible = False
                    lblImporto.Left = 40%x
                End If

            End If
        Else 'Not visible
            If Pnl.NumberOfViews > 0 Then
                Pnl.RemoveAllViews 'Remove none visable item/layouts from the list/main layout
            End If
        End If
    Next
End Sub

Tell me if you need a complete example

Thank you
 

mangojack

Expert
Licensed User
Longtime User
Upvote 0

Schakalaka

Active Member
Licensed User
Longtime User
here.
the activity is "alltransactions"

I have write a coment on error line.

Thank you
 

Attachments

  • MIeFinanzeSQLwithCLV_error.zip
    165.4 KB · Views: 38
Upvote 0

mangojack

Expert
Licensed User
Longtime User
No , just a small example that highlight your problem.

Just to update you . I have had a long look at your app and are non the wiser what is the root cause of your issue.

I cant make a connection between missing db fields error and the CLV Swipe return values ?

Hopefully someone can pick up the ball and help you.

If not possibly a bare / simplified sample to expose the issue might help.
 
Upvote 0

Schakalaka

Active Member
Licensed User
Longtime User
hello,
thank you for take a look.
I have take from forum the example of lazy loading cardview.

My question are always 2.
where and how put the code for get the swipe?

all the code should be this:

on activity create:

B4X:
    Swipe.Initialize(CLV1, Me, "Swipe")
    Swipe.ActionColors = CreateMap("Delete": xui.Color_Red, "Do Something Else": xui.Color_Green, _
        "Action 1": xui.Color_Red, "Action 2": xui.Color_Blue, "Action 3": xui.Color_Yellow)


this is for add to the clv panel, but I don't know where
B4X:
Swipe.CreateItemValue("", Array("Delete", "Do Something Else"))

If i add it after

CLV1.Add(p, cd)

it return this error
"java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first."

Attach the example
 

Attachments

  • swipe Card example.zip
    118.1 KB · Views: 43
Upvote 0
Top