saludos
anterior mente realice un poyecto en b4a, una calculadora , la cual funcionaba correctamente,
recientemente actualice la version mas reciente de b4a, realice, volvi a generar el apk del proyecto, al momemto de procesar para genrar resultados genera error:
Error occurred on line: 279 (B4XTable)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.objects.B4XViewWrapper com.ipvlsmcalc.b4xfloattextfield._mbase' on a null object reference
Anterirormente no tuve ese problema, no edite nada del codigo, revise por consola y esta generando valores,., pero al momento de ser mostrados por B4xTable salta ese error
MAIN ACTIVITY
Declaracioin de variables
Proceso para calcular
ACTIVITY RESULTADOS
En activity Create (Resultados) llamo al control tblResults (Bx$Table) y lo lleno con la informacion contenida en el objetos Datos (List) declarada en MAIN Activity
En el proceso tblResults_DataUpdated se pintan los textos dentro las celdas del B4XTable
Debo mencionar no editan nada del codigo y este funcionaba correctamente, sin embargo ahora se traba justo en tblResults_DataUpdated, la aplicacion se cierra, a pesar de tener try.. catch
anterior mente realice un poyecto en b4a, una calculadora , la cual funcionaba correctamente,
recientemente actualice la version mas reciente de b4a, realice, volvi a generar el apk del proyecto, al momemto de procesar para genrar resultados genera error:
Error occurred on line: 279 (B4XTable)
java.lang.NullPointerException: Attempt to read from field 'anywheresoftware.b4a.objects.B4XViewWrapper com.ipvlsmcalc.b4xfloattextfield._mbase' on a null object reference
Anterirormente no tuve ese problema, no edite nada del codigo, revise por consola y esta generando valores,., pero al momento de ser mostrados por B4xTable salta ese error
MAIN ACTIVITY
Declaracioin de variables
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim VLSM As classVLSMCIDR
Dim Datos As List
Dim NmrHosts As Int
Dim txtMainIPAddr, txtBroadCast, txtMainNetMask, txtPrefijo,strMode As String
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 txtIPAddr, txtHosts, vecTxtR(30) As EditText
End Sub
B4X:
Sub btnProcCIDR_Click
Dim SuperNet As classVLSMCIDR
Dim nmrR,num As Int
Dim bBuildT As Boolean
Try
SuperNet.Initialize
SuperNet.TotalSubRedes(Indice)
SuperNet.ListaSubRedes(vecTxtR)
bBuildT=SuperNet.CalcSuperNet()
If bBuildT=True Then
nmrR=SuperNet.ResultTotalSubRedes
txtMainIPAddr=SuperNet.ResultSuperNetAddress
txtBroadCast=SuperNet.ResultSuperNetBroadCast
txtMainNetMask=SuperNet.ResultSuperNetMask
txtPrefijo=SuperNet.ResultSuperNetPrefix
Datos.Initialize
Datos.Add(Array("S.NET.",SuperNet.ResultSuperNetAddress,SuperNet.ResultSuperNetBinary,SuperNet.ResultSuperNetBroadCast,SuperNet.ResultSuperNetBinaryBroadCast,SuperNet.ResultSuperNetMask,SuperNet.REsultSupernetBynaryMask,SuperNet.ResultSuperNetPrefix))
For num=0 To nmrR
Datos.Add(Array("Net." & (num+1),SuperNet.ResultSubNetAddress(num),SuperNet.ResultSubNetBinary(num),SuperNet.ResultSubNetBroadCast(num),SuperNet.ResultSubNetBinaryBroadCast(num),SuperNet.ResultSubNetMask(num),SuperNet.ResultSubNetMaskBinary(num),SuperNet.ResultSubNetPrefix(num)))
Next
strMode="CIDR"
Sleep(300)
telefono.SetScreenOrientation(1)
StartActivity(Resultados)
End If
'//Tiempo.Enabled=True
Catch
Log("btnProcCIDR: " & LastException)
End Try
End Sub
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim bBin=True As Boolean
Dim telefono As Phone
Private btnVI As Button
Private cmdBinDec As Button
Private pnlLabels As B4XView
Private tblResults As B4XTable
Private lblMainIPAddr As Label
Private lblBroadCast As Label
Private lblMainNetMask As Label
Private lblPrefijo As Label
Dim colNmr As B4XTableColumn
Dim colRqs As B4XTableColumn
Dim colRP As B4XTableColumn
Dim colRPB As B4XTableColumn
Dim colBC As B4XTableColumn
Dim colBCB As B4XTableColumn
Dim colMS As B4XTableColumn
Dim colMSB As B4XTableColumn
Dim colPR As B4XTableColumn
Dim colDP As B4XTableColumn
Private lblTipoResp As Label
End Sub
En activity Create (Resultados) llamo al control tblResults (Bx$Table) y lo lleno con la informacion contenida en el objetos Datos (List) declarada en MAIN Activity
B4X:
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Try
telefono.SetScreenOrientation(0)
Activity.LoadLayout("IPResults")
tblResults.RowHeight=7%y
Sleep(0)
tblResults.SearchField.mBase.Visible=False
lblMainIPAddr.Text="Main Addr:"&Main.txtMainIPAddr
lblBroadCast.Text="BroadCast:"&Main.txtBroadCast
lblMainNetMask.Text="Net Mask:"&Main.txtMainNetMask
lblPrefijo.Text="Prf."&Main.txtPrefijo
cmdBinDec.Text="Mostrar Binario"
lblTipoResp.Text=Main.strMode
If Main.strMode="VLSM" Then
colNmr=tblResults.AddColumn("Nro.", tblResults.COLUMN_TYPE_TEXT)
colRqs=tblResults.AddColumn("Req.", tblResults.COLUMN_TYPE_TEXT)
colRP=tblResults.AddColumn("Direccion", tblResults.COLUMN_TYPE_TEXT)
colRPB=tblResults.AddColumn("Direccion", tblResults.COLUMN_TYPE_TEXT)
colBC=tblResults.AddColumn("BroadCast", tblResults.COLUMN_TYPE_TEXT)
colBCB=tblResults.AddColumn("BroadCast", tblResults.COLUMN_TYPE_TEXT)
colMS=tblResults.AddColumn("Mascara", tblResults.COLUMN_TYPE_TEXT)
colMSB=tblResults.AddColumn("Mascara", tblResults.COLUMN_TYPE_TEXT)
colPR=tblResults.AddColumn("Prefijo", tblResults.COLUMN_TYPE_TEXT)
colDP=tblResults.AddColumn("Disp.", tblResults.COLUMN_TYPE_TEXT)
colNmr.Width=8%x
colRqs.Width=8%x
colRP.Width=22%x
colBC.Width=22%x
colMS.Width=22%x
colPR.Width=8%x
colDP.Width=8%x
colRPB.Width=1dip
colBCB.Width=1dip
colMSB.Width=1dip
Else If Main.strMode="CIDR" Then
colNmr=tblResults.AddColumn("Nro.", tblResults.COLUMN_TYPE_TEXT)
colRP=tblResults.AddColumn("Direccion", tblResults.COLUMN_TYPE_TEXT)
colRPB=tblResults.AddColumn("Direccion", tblResults.COLUMN_TYPE_TEXT)
colBC=tblResults.AddColumn("BroadCast", tblResults.COLUMN_TYPE_TEXT)
colBCB=tblResults.AddColumn("BroadCast", tblResults.COLUMN_TYPE_TEXT)
colMS=tblResults.AddColumn("Mascara", tblResults.COLUMN_TYPE_TEXT)
colMSB=tblResults.AddColumn("Mascara", tblResults.COLUMN_TYPE_TEXT)
colPR=tblResults.AddColumn("Prefijo", tblResults.COLUMN_TYPE_TEXT)
colNmr.Width=10%x
colRP.Width=25%x
colBC.Width=25%x
colMS.Width=25%x
colRPB.Width=1dip
colBCB.Width=1dip
colMSB.Width=1dip
colPR.Width=8%x
End If
tblResults.SearchField=Null
tblResults.SetData(Main.Datos)
Catch
Log("Activity_Create: "&LastException)
End Try
End Sub
En el proceso tblResults_DataUpdated se pintan los textos dentro las celdas del B4XTable
B4X:
Sub tblResults_DataUpdated()
Dim pnlRPB,pnlMSB,pnlRP,pnlNro,pnlBC,pnlMS,pnlPR,pnlReq As B4XView
Dim cmpV,chrV,strV,cmpB,chrB,strB,cmpN As String
Dim nmc,lnD,clr,lnV,pp,FlnD,intW As Int
Dim Fila As Map
Dim FlId As Long
Dim fnt,ltr As Typeface
Try
fnt=Typeface.DEFAULT
ltr=Typeface.DEFAULT_BOLD
For i = 0 To tblResults.VisibleRowIds.Size - 1
FlId = tblResults.VisibleRowIds.Get(i)
If FlId > 0 Then
Fila = tblResults.GetRow(FlId)
pnlNro=colNmr.CellsLayouts.Get(i + 1)
pnlRPB = colRPB.CellsLayouts.Get(i + 1)
pnlMSB = colMSB.CellsLayouts.Get(i + 1)
pnlRP=colRP.CellsLayouts.Get(i + 1)
pnlMS=colMS.CellsLayouts.Get(i + 1)
pnlBC=colBC.CellsLayouts.Get(i + 1)
pnlPR=colPR.CellsLayouts.Get(i + 1)
pnlRPB.GetView(0).TextColor=Colors.White
pnlMSB.GetView(0).TextColor=Colors.White
pnlRP.GetView(0).TextColor=Colors.White
pnlMS.GetView(0).TextColor=Colors.White
pnlBC.GetView(0).TextColor=Colors.White
pnlPR.GetView(0).TextColor=Colors.White
cmpV = Fila.Get(colRPB.Id)
cmpB = Fila.Get(colMSB.Id)
cmpN=Fila.Get(colNmr.Id)
strV=""
strB=""
If Main.strMode="VLSM" Then
lnD=Fila.Get(colPR.Id)
If lnD>8 Then pp=1
If lnD>16 Then pp=2
If lnD>24 Then pp=3
FlnD=lnD-(pp+1)
pnlReq=colRqs.CellsLayouts.Get(i+1)
pnlReq.GetView(0).TextColor=0xFF1370D5
pnlMS.GetView(0).TextColor=0xFF1370D5
pnlPR.GetView(0).TextColor=0xFF1370D5
If cmpN="N.Err." Then
pnlNro.Getview(0).TextColor=Colors.Red
pnlRPB.GetView(0).TextColor=Colors.Red
pnlMSB.GetView(0).TextColor=Colors.Red
pnlRP.GetView(0).TextColor=Colors.Red
pnlMS.GetView(0).TextColor=Colors.Red
pnlBC.GetView(0).TextColor=Colors.Red
pnlPR.GetView(0).TextColor=Colors.Red
End If
Else if Main.strMode="CIDR" Then
If i=0 And cmpN="S.NET." Then
pnlRP.GetView(0).TextColor=0xFF1370D5
pnlMS.GetView(0).TextColor=0xFF1370D5
pnlNro.GetView(0).TextColor=0xFF1370D5
pnlBC.GetView(0).TextColor=0xFF1370D5
pnlPR.GetView(0).TextColor=0xFF1370D5
pnlRPB.GetView(0).TextColor=0xFF1370D5
Else
pnlRP.GetView(0).TextColor=Colors.White
pnlMS.GetView(0).TextColor=Colors.White
pnlNro.GetView(0).TextColor=0xFF1370D5
pnlBC.GetView(0).TextColor=Colors.White
pnlPR.GetView(0).TextColor=Colors.White
pnlRPB.GetView(0).TextColor=Colors.White
End If
lnD=Main.txtPrefijo
If lnD>8 Then pp=1
If lnD>16 Then pp=2
If lnD>24 Then pp=3
FlnD=lnD+(pp-1)
End If
End If
Next
Catch
Log("tblResults_DataUpdated:"&LastException)
End Try
End Sub
Debo mencionar no editan nada del codigo y este funcionaba correctamente, sin embargo ahora se traba justo en tblResults_DataUpdated, la aplicacion se cierra, a pesar de tener try.. catch