Hello !
I have partly moved on from my problem, but not very far ! The program is coded as below - some lines have been given numbers for clarity
Th initialise problem is not listed as an error since I put in the extra coding to assign values to the variables ( I hope this is correct). I have not put the Design here but I have (hopefully) attached a zipped version of the program to this request.
The progam now completes a compilation, and my Android device , whilst apparently allowing it to run, closes immediately and the following message apppear on the log file
Once again thanks to anyone who can help - If I can't get this basic program to work then I cannot continue !
The top LOG files read (after compilation)
Main - 25: Layout file 'program01.bal' is not used. Are you missing a call to Activity.LoadLayout? (warning #16)
The main LOG file read as below, saying that there was a problem with line 28 lblNumber1.Text = Number1
Logger connected to: motorola moto g15
--------- beginning of main
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create (first time) **
Error occurred on line: 28 (B4XMainPage)
java.lang.RuntimeException: Type does not match (class java.lang.String)
at anywheresoftware.b4a.objects.B4XViewWrapper.typeDoesNotMatch(B4XViewWrapper.java:405)
at anywheresoftware.b4a.objects.B4XViewWrapper.asLabelWrapper(B4XViewWrapper.java:215)
at anywheresoftware.b4a.objects.B4XViewWrapper.setText(B4XViewWrapper.java:229)
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:348)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:157)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at b4a.Program01.b4xmainpage._newproblem(b4xmainpage.java:72)
at b4a.Program01.b4xmainpage._b4xpage_created(b4xmainpage.java:63)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:318)
at anywheresoftware.b4a.debug.Debug.CallSubNew2(Debug.java:285)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.keywords.Common.CallSubDebug2(Common.java:1140)
at b4a.Program01.b4xpagesmanager._createpageifneeded(b4xpagesmanager.java:1068)
at b4a.Program01.b4xpagesmanager._showpage(b4xpagesmanager.java:425)
at b4a.Program01.b4xpagesmanager._addpage(b4xpagesmanager.java:245)
at b4a.Program01.b4xpagesmanager._addpageandcreate(b4xpagesmanager.java:259)
at b4a.Program01.b4xpagesmanager._initialize(b4xpagesmanager.java:165)
at b4a.Program01.main._activity_create(main.java:415)
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:157)
at b4a.Program01.main.afterFirstLayout(main.java:105)
at b4a.Program01.main.access$000(main.java:17)
at b4a.Program01.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:959)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loopOnce(Looper.java:234)
at android.os.Looper.loop(Looper.java:319)
at android.app.ActivityThread.main(ActivityThread.java:8754)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:962)
There was more if needed !
The Program
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private btnAction As B4XView = "Enter the result" & CRLF & "and click on OK"
Private edtResult As B4XView = " "
Private lblComments As B4XView = " "
Private lblMathSign As B4XView = "+"
Private lblNumber1 As B4XView = "0"
Private lblNumber2 As B4XView = "0"
Public Number1,Number2 As Int
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
NewProblem
End Sub
Private Sub NewProblem
26 Number1 = Rnd(1,10)
27 Number2 = Rnd(1,10)
28 lblNumber1.Text = Number1
29 lblNumber2.Text = Number2
30 lblComments.Text = "Enter the result" & CRLF & "and click on OK"
edtResult.Text = ""
lblMathSign.Text = "+"
End Sub
Private Sub Button1_Click
If btnAction.Text = "O K" Then
If edtResult.Text = "" Then
MsgboxAsync("No result entered", "E R R O R")
Else
CheckResult
End If
Else
NewProblem
btnAction.Text = "O K"
End If
End Sub
Private Sub CheckResult
If edtResult.Text = Number1 + Number2 Then
lblComments.Text = "G O O D result" & CRLF & "Click on NEW"
btnAction.Text = "NEW"
Else
lblComments.Text = "Wrong result " & CRLF & "Try again " & CRLF & "Click OK"
End If
End Sub