Android Question table version 3.26

manuelsalazar

Member
Licensed User
Hi :

I´m using table 3.26 , and have one problem, when I open a table , close and reopen it works fine.

But if I open table and sort by any column (like the last column) after open it, then close and reopen send me the error of the attached file.
as you can see doesn't initialize the sort column.

thanks in advanced.

Manuel Salazar
 

Attachments

  • thumbnail_Screenshot_20200928-193335.png
    thumbnail_Screenshot_20200928-193335.png
    93.2 KB · Views: 120

manuelsalazar

Member
Licensed User
B4X:
Sub btnProducto_Click
    If Table1.Visible = True Then
'        btnExistencia.Color = Colors.Blue
        Table1.ClearAll
        Table1.RefreshTable
        Table1.Visible = Not(Table1.Visible)
        edtPRODUCTO.Text = txt2
        edtPRODUCTO_FINTEXTO
        edtPRODUCTO.RequestFocus
    Else
        Table1.clearAll
        Table1.RefreshTable
        Table1.Visible = False
        txt2=""
'        btnExistencia.Color = Colors.Red
        ConsultaProducto
    End If
'    edtEXISTENCIAS.Visible = False
End Sub   
    
    
Sub ConsultaProducto
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("select_catinven", Null)
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        req.PrintTable(res)
        Dim x As Int=1
        Dim AProducto As String
        Dim ANombre As String
        Dim ATienda As String
        Dim AExistencia As String
        Dim ALinea As String
        Dim AAlterna As String
        Dim APrecio1, APrecio2,APrecio3 As String
        Table1.Visible = True
        Table1.MultiSelect = True
'        Table1.Initialize(Me, "Table1", 3, Gravity.CENTER_HORIZONTAL, True)
'        Table1.CellAlignment = Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL)
'        Table1.HeaderColor = Colors.Gray
'        Table1.HeaderTextColor = Colors.Black
'        Table1.TextColor = Colors.Blue
'        Table1.TableColor = Colors.Red
        Table1.RowHeight = 20dip
        Table1.MultiSelect = False
        Table1.SortColumn = True
        Table1.SingleLine = True
        Table1.LineWidth = 3dip
        Table1.TextSize = 11
        Table1.FastScroll = True
        Table1.FastScrollMinItems = 15
        Table1.FastScrollColumnIndex = 0
        Dim Alignments() As Int
        Alignments = Array As Int(Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.LEFT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL), Bit.Or(Gravity.RIGHT, Gravity.CENTER_VERTICAL))
        '       Table1.SetHeaderAlignments(Alignments)
        Table1.SetCellAlignments(Alignments)

        Dim tf() As Typeface
        tf = Array As Typeface(Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT, Typeface.DEFAULT,Typeface.DEFAULT,Typeface.DEFAULT,Typeface.DEFAULT)

        Table1.SetTypeFaces(tf)
        Table1.SetHeaderTypeFaces(tf)
        Table1.SetHeader(Array As String("Clave", "Producto", "Linea", "Codigo GS1", "Existencia", "Precio1", "Precio2", "Precio3"))
        Table1.SetColumnsWidths(Array As Int(25%x, 80%x, 20%x, 26%x, 20%x, 20%x, 20%x, 20%x))
        Table1.ClearAll

        For Each records() As Object In res.Rows
            AProducto=records(0)
            ANombre=records(1)
            ALinea = records(2)
            AAlterna = records(3)
            AExistencia=NumberFormat(records(4),0,0)
            APrecio1="$ "&NumberFormat2(records(5),1,2,2,True)
            APrecio2="$ "&NumberFormat2(records(6),1,2,2,True)
            APrecio3="$ "&NumberFormat2(records(7),1,2,2,True)
            Table1.AddRow(Array As String(AProducto,ANombre,ALinea,AAlterna,AExistencia,APrecio1, APrecio2, APrecio3))
        Next
        j.Release
    Else
        Msgbox("NO HAY CONEXION CON EL SERVIDOR DE DATOS.","ALERTA !!!!!")
        Log("ERROR: " & j.ErrorMessage)
        j.Release
    End If
'    j.Release
End Sub
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
.. and please, post the log as text. Right click on the logs->copy lines.

Have you checked the line after: ZY3-24B JUGUETE....
some NULL or strange value?
 
Upvote 0

manuelsalazar

Member
Licensed User
here are the logs in debug mode.

ZXG-3903 ZXG-3903 RELOJ 10 RELOJ 7503030699013 0.0 72.0 60.0 0.0
ZXG-3911 ZXG-3911 RELOJ RELOJ 1.0 0.0 0.0 0.0
ZXG-3911A/C ZXG-3911A/C RELOJ RELOJ 7503030699020 0.0 78.0 65.0 0.0
ZXG-3919K ZXG-3919K RELOJ RELOJ 0.0 0.0 0.0 0.0
ZXG-3920 ZXG-3920 RELOJ10 RELOJ 7503030394543 0.0 170.0 142.0 149.0
ZXG-3924S ZXG-3924S RELOJ 20 RELOJ 7503030699044 0.0 62.0 52.0 0.0
ZXG-3974 ZXG-3974 RELOJ RELOJ 7503030699068 0.0 126.0 105.0 118.0
ZXG-8805 ZXG-8805 RELOJ10 RELOJ 7503030513210 0.0 110.0 92.0 105.0
ZXG-9120 ZXG-9120 RELOJ 10 RELOJ 7503030394550 1.0 66.0 55.0 68.0
ZXG-9169 ZXG-9169 RELOJ RELOJ 7503030513180 -1.0 97.0 81.0 94.0
ZXG-988C ZXG-988C RELOJ RELOJ 7503030699082 0.0 158.0 132.0 0.0
ZXG3911A/C ZXG3911A/C RELOJ 10 RELOJ 0.0 0.0 0.0 0.0
ZXX99116A ZXX99116A RELOJ DE PARED RELOJ 0.0 0.0 0.0 0.0
ZXX99119A ZXX99119A RELOJ DE PARED RELOJ 0.0 50.0 50.0 0.0
ZXYM-2560 ZXYM-2560 RELOJ DE PARED RELOJ 0.0 0.0 0.0 0.0
ZXYM-2569 ZXYM-2569 RELOJ DE PARED CAFÉ CIRCULAR RELOJ 7503030699143 0.0 66.0 55.0 0.0
ZY3-24B ZY3-24B JUGUETE JUGUE 7503030394895 197.0 170.0 155.0 145.0
Error occurred on line: 2848 (Table)
java.lang.ClassCastException: anywheresoftware.b4a.BALayout cannot be cast to android.widget.TextView
at b4a.CONSULTA.table._settextsize(table.java:467)
at b4a.CONSULTA.kardex$ResumableSub_ConsultaProducto.resume(kardex.java:752)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:43)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:267)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:137)
at anywheresoftware.b4a.BA$2.run(BA.java:387)
at android.os.Handler.handleCallback(Handler.java:836)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:203)
at android.app.ActivityThread.main(ActivityThread.java:6314)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1063)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:924)



here is the line in the table code :


Public Sub setTextSize(Size As Float)
cTextSize = Size

Private i As Int

If mNumberOfFixedColumns = 0 Then
If Header.IsInitialized Then
For i = 0 To Header.NumberOfViews - 1
Dim lbl As Label
lbl = Header.GetView(i) <-------- error
lbl.TextSize = cTextSize
Next
End If

also here I send the pictures.

thanks in advanced
Manuel Salazar
 

Attachments

  • thumbnail_IMG_20200929_160604.jpg
    thumbnail_IMG_20200929_160604.jpg
    384.6 KB · Views: 101
  • thumbnail_IMG_20200929_160743.jpg
    thumbnail_IMG_20200929_160743.jpg
    232.6 KB · Views: 103
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
Because my coding is so bad I do a lot of debugging
The first thing I would do is log(i) so I could see which header view its having a problem with
In general when I strike a problem (which seems like all the time) I start coding in a way that the application itself can start telling me what's wrong with it
 
Upvote 0

manuelsalazar

Member
Licensed User
I think that the header with the problem is the one that has the arrow sign that is SORTED , it is because the table routine doesn't clear the arrow, and can't read correctly the header!!!
 
Upvote 0

Unobtainius

Active Member
Licensed User
Longtime User
I think that the header with the problem is the one that has the arrow sign that is SORTED , it is because the table routine doesn't clear the arrow, and can't read correctly the header!!!
You can prove this by logging i, then you run your app up and change the sorted column to the first column and if then reload the table and if it claps out with i =0 then at least you know what battle you are fighting
 
Upvote 0
Top