Android Question Custom List View strange error

Dianzoa

Active Member
Licensed User
I have 2 functions, one that load the header in a customlistview, and other that load the detail, the header loads well, however, when try to create the items for the detail, i got that my CLV is a null object, and the app crashes. How can the CLV got to be null if the activity es not finish?
This is the call that works
B4X:
pedidosDetalleTarjeta.Add(CreateItemPedidoCab(pedidosDetalleTarjeta.AsView.Width,Main.idpedido,nombre_cliente.Text,direccion.Text,estado.Text,fecha_pedido.Text),"")

And this crashes, saying that the CLV is a null object, I don't get it
B4X:
pedidosDetalleTarjeta.Add(CreateItemPedidoDet(pedidosDetalleTarjeta.AsView.Width,Main.idpedido,nroEntrega,distest,direccionPedidoDet,zonaDet,estadoPedidoDet,recorrido,observacion),"")
 

Dianzoa

Active Member
Licensed User
Sorry, I will try to elaborate more.
I have and endpoint for the header data, the data retrieved successfully with poststring. I called the CLV.add with the createitemCab, and the card is created and added.
I have another endpoint for the detail data, the data retrieved successfully, I called the CLV.add again with the createitemDet, but this time fails with this error. This failed before the createitemDet is even called, because apparently the CLV is already null at that point in code, don't know why. The detail data is retrieved immediately after the header.
B4X:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.lang.String.equals(java.lang.Object)' on a null object reference

Even to try to clear the CLV, just for testing, with CLV.clear, gets the same null error thing. It is like suddenly the CLV lost its reference.
Do You need more code to?

Cheers and thanks in advanced.
 
Last edited:
Upvote 0

Dianzoa

Active Member
Licensed User
This is the whole function, the data is retrieved ok.

B4X:
Private Sub traerPedidoDetalle
    pedidosDetalle.Initialize
    Dim direccion_google As String
  
    If nro_pedido.Text <> "" Then
          
'        pedidosDetalleTarjeta.Clear
        pedidosDetalle.Clear
        'pedidosCL.Clear
        Private ServerUrl As String
        Private J As HttpJob
        ServerUrl = "api/traerPedidoDetalle"
      
        j.Initialize("", Me)
        j.PostString(ServerUrl,"idpedido="&Main.idpedido)
        Wait For (j) JobDone(Job As HttpJob)
        If Job.Success Then
            Dim parser As JSONParser
            Dim response As String = Job.GetString
            'Msgbox(response,"")
            parser.Initialize(response)
            Dim rows As List
            'Log(parser)
            rows = parser.NextArray
            If rows.Size  = 0 Then
                'sacar un mensaje que avise que hay entregas pendientes
                MsgboxAsync("No se encontraron detalles ", "Pedido Detalle")
            else if rows.Size > 0 Then
              
                conPedido.Visible = True
                sinPedido.Visible = False
                For i = 0 To rows.Size-1
                  
                    Dim m As Map
                    Dim recorrido As String = ""
                    m = rows.Get(i)
                    fecha = m.Get("fecalta")
                    nroEntrega = m.Get("item")
                    fechaPedidoDet = sf.Mid(fecha,7,13)
                    DateTime.DateFormat = "dd/MM/yyyy HH:mm"
                  
                    recorrido = m.Get("distancia_recorrida")
                    direccionPedidoDet = m.Get("direccion")
                  
                    observacion = m.Get("observacion")
                    distest = m.Get("distancia_estimada")
                    estadoPedidoDet = m.Get("estado")
                    zonaDet = m.Get("zona")
                  
                  'In this call is the error
pedidosDetalleTarjeta.Add(CreateItemPedidoDet(pedidosDetalleTarjeta.AsView.Width,Main.idpedido,nroEntrega,distest,direccionPedidoDet,zonaDet,estadoPedidoDet,recorrido,observacion),"") 
                Next
            End If
            'aceptar_pedido.Visible = True
'        Rechazar_pedido.Visible = True
            refrescar.Visible = True
            finalizar.Visible = False
        Else
            Log(Job.ErrorMessage)
        End If
    End If
End Sub
 
Upvote 0

Dianzoa

Active Member
Licensed User
I will check the B4XPages, looks awesome, for what I've just read, I can have a goof use of it. Thanks man! It looks quite similar to ABMaterial which I have used in the past. Notifications and such, will still be functional, like a "normal" B4A app?
 
Upvote 0
Top