Android Question error while opening layout

Makumbi

Active Member
Licensed User
B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim cursor1 As Cursor
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.
    Private B4XTable1 As B4XTable
    
    Dim Classt As Label
    Dim streamd As Label
    Dim Tname As Label
    Dim MobileNo As Label
    Dim MobileNo2 As Label
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("Classteacher")
    
    ShowTable
End Sub

Sub Activity_Resume

End Sub


Sub B4XTable1_CellClicked (ColumnId As String, RowId As Long)
    Log(ColumnId)
    'Dim SQLQry As String = "DELETE FROM Studentphoto2"
    'Starter.SQL1.ExecNonQuery(SQLQry)
    'If IsConnectedToInternet = True Then
        If ColumnId = "Student Names" Then
            Classt.Text = B4XTable1.GetRow(RowId).Get("Class")
            streamd.Text = B4XTable1.GetRow(RowId).Get("Stream")
        '    StudentName.Text = B4XTable1.GetRow(RowId).Get("Student Names")
        ProgressDialogShow2("Loading Classteacher Details  Please Wait...",False)
        Sleep(50)
        Dim holdnt As String
        Dim rstnt As ResumableSub = Loadterms(holdnt)
        Wait For(rstnt) Complete (Result As String)
        ProgressDialogHide
    End If
End Sub
Sub IsConnectedToInternet As Boolean
    Dim r As Reflector
 
    r.Target = r.GetContext
    r.Target = r.RunMethod2("getSystemService", "connectivity", "java.lang.String")
    r.Target = r.RunMethod("getActiveNetworkInfo")
 
    If r.Target <> Null Then
        Return r.RunMethod("isConnectedOrConnecting")
    End If
 
    Return False
End Sub

Sub Loadterms (a As String) As ResumableSub
    'Log(a)
    If IsConnectedToInternet= True Then

                
        Dim jt As HttpJob
        jt.Initialize("", Me)
        jt.Download("http://kccug.com/KabojjaApp/HandlerVBGteacher.ashx?customerid=" & Classt.Text & "&customerid2=" & streamd.Text)
        'Sleep(6000)
        'jt.GetRequest.Timeout = 2000 ' 10 seconds
        Wait For (jt) JobDone(jt As HttpJob)
        If jt.Success Then ' if job is success (http status code 200)
            Dim RetVal As String
            RetVal = jt.GetString
            If jt.GetString = "[]" Then
                'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
                '    Return
            
            Else
            
                Dim jpt As JSONParser
                jpt.Initialize(jt.GetString)
                '    Log(jpt) ' will pr
                Dim quotes As List = jpt.NextArray
                For Each quot As Map In quotes
                    Log("Teacher: " & quot.Get("Teacher"))
                    Log("Phone: " & quot.Get("Phone"))
                    Log("Phone: " & quot.Get("Phone2"))
                    
                    Tname.Text=quot.Get("Teacher")
                    MobileNo.Text=quot.Get("Phone")
                    MobileNo2.Text=quot.Get("Phone2")
                Next
            
                Return "Active"
            End If
        End If
        'jt.Release
        
                    
    
    Else
        MsgboxAsync("Error Connecting to the Server Please Check Your Internet Connection Or Load Mbs","Server Error")
        
        't1.Enabled = False

    End If
End Sub
Sub ShowTable
    B4XTable1.Clear
    B4XTable1.AddColumn("Student Names", B4XTable1.COLUMN_TYPE_TEXT).Width=150dip
    B4XTable1.AddColumn("Class", B4XTable1.COLUMN_TYPE_TEXT).Width=70dip
    B4XTable1.AddColumn("Stream", B4XTable1.COLUMN_TYPE_TEXT).Width=70dip
    B4XTable1.AddColumn("Account", B4XTable1.COLUMN_TYPE_TEXT)
    Dim data As List
    data.Initialize
    
    cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
    If cursor1.RowCount > 0 Then
        cursor1.Position =0
        Dim Phonet As String
        Phonet = cursor1.Getstring("Phone")
            
    End If
    Dim rs As ResultSet  = Starter.SQL1.ExecQuery2("SELECT DISTINCT Names,Class || Stream As CS,Class,Stream,Account,Amount As Balance FROM Balances WHERE Phone = ?", Array As String(Phonet))
    Do While rs.NextRow
        Dim row(4) As Object
    
        row(0) = rs.GetString("Names")
        row(1) = rs.GetString("Class")
        row(2) = rs.GetString("Stream")
        row(3) = rs.GetString("Account")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
    'B4XTable1.VisibleColumns.RemoveAt(B4XTable1.VisibleColumns.IndexOf("Account"))
End Sub

Sub Activity_Pause (UserClosed As Boolean)
Activity.Finish
End Sub

B4X:
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
Class not found: b4a.example.b4xtable, trying: smiskabojja.com.b4xtable
0
Class not found: b4a.example.b4xfloattextfield, trying: smiskabojja.com.b4xfloattextfield
12
** Activity (main) Pause, UserClosed = false **
** Activity (classteacher) Create, isFirst = true **
classteacher_activity_create (java line: 375)
java.lang.RuntimeException: java.lang.RuntimeException: Field b4xtable1 was declared with the wrong type.
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at smiskabojja.com.classteacher._activity_create(classteacher.java:375)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
    at smiskabojja.com.classteacher.afterFirstLayout(classteacher.java:104)
    at smiskabojja.com.classteacher.access$000(classteacher.java:17)
    at smiskabojja.com.classteacher$WaitForLayout.run(classteacher.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.RuntimeException: Field b4xtable1 was declared with the wrong type.
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:431)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
    ... 14 more
java.lang.RuntimeException: java.lang.RuntimeException: Field b4xtable1 was declared with the wrong type.
 

DonManfred

Expert
Licensed User
I posted a link to java packagenaming and also told that it is a google guideline.
Why are you using another packagename then? Just ignore any suggestions? good idea


Additional you need to remove the view from your layout and add it again into the layout using your apps packagename.
 
Top