Error question

vpires

Member
Licensed User
Longtime User
Hello. Spend two hours at this code, and i can't see why it fails on the second call.

with only one call to buildGenTab, all works as expected. With two calls, the second one fails with a java exception on the line T.p.Height = TabTabelas.Height - 50dip.

But if i comment that and the next line, all works again as expected.

TIA
Nelson

B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Type TabStruct(p As Panel, g As xnGrid, c() As xnGridCol )
    
End Sub

Sub Globals
   'These global variables will be redeclared each time the activity is created.
   'These variables can only be accessed from this module.

   Dim TabTabelas As TabHost
   Dim FamiliasPanel As Panel
   Dim PagamentoPanel As Panel
      
   Dim Tab1 As TabStruct
   Dim Tab2 As TabStruct
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
   'Do not forget to load the layout file created with the visual designer. For example:
   Activity.LoadLayout("tabelas")

   Tab1.Initialize 
   Tab2.Initialize 
   BuildGenTab(Tab1,"Familias",Array As String("Codigo","Descricao"),Array As String("Codigo","Descricaoo"), _
                                     Array As Int(40dip,100%x-40dip))
                             
   BuildGenTab(Tab2,"Pagamento",Array As String("Codigo","Descricao"),Array As String("Codigo","Descricao"), _
                                     Array As Int(40dip,100%x-40dip))
                             
   
    'TabTabelas.addTab2("Familias",FamiliasPanel)
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub
Sub BuildGenTab(T As TabStruct,tabela As String,headers() As String,campos() As String, lens() As Int) As Panel
    Dim  n As Int
   
    T.p.Initialize("panel")
   TabTabelas.addTab2(tabela,T.p)
   
   T.p.Height = TabTabelas.Height - 50dip  
   T.p.Width = TabTabelas.Width 
   'p.Background =  
   ' Grid
   T.g.Initialize("t.g")
   T.g.RowHeight = 48dip 
   T.g.RowHeight = 48dip 
   T.g.HeaderHeight = 30dip
    T.g.HeaderTextSize = 20
    T.g.RowTextSize = 20 
    T.g.HeaderTextColor = Colors.Yellow
      T.g.RowTextColor = Colors.white
      T.g.SelectedOddColor = Colors.Magenta
    T.g.SelectedEvenColor = Colors.Magenta
   ' Colunas
   Dim c(headers.Length) As xnGridCol 
   For n=0 To headers.Length - 1
      c(n).Initialize( headers(n),campos(n),lens(n) )
      T.g.AppendCol ( c(n) )
   Next 
   T.c = c
        ' fetch data
   T.g.AppendRow(Array As String("aa","aa"))
   T.p.AddView(T.g,0,0,100%x,100%y)
   T.g.GridCreate2(False,True)
    
   
End Sub
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…