Android Question java.lang.RuntimeException: Object should first be initialized (EditText).[SOLVED]

So this I would think should be straight forward. When I push the button to switch activities, I get this error...
B4X:
Copying updated assets files (1)
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
Error occurred on line: 38 (Main)
java.lang.RuntimeException: Object should first be initialized (EditText).
	at anywheresoftware.b4a.AbsObjectWrapper.getObject(AbsObjectWrapper.java:50)
	at anywheresoftware.b4a.objects.TextViewWrapper.getText(TextViewWrapper.java:36)
	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:144)
	at b4a.example.locals.initializeGlobals(locals.java:320)
	at b4a.example.locals.afterFirstLayout(locals.java:101)
	at b4a.example.locals.access$000(locals.java:17)
	at b4a.example.locals$WaitForLayout.run(locals.java:82)
	at android.os.Handler.handleCallback(Handler.java:873)
	at android.os.Handler.dispatchMessage(Handler.java:99)
	at android.os.Looper.loop(Looper.java:193)
	at android.app.ActivityThread.main(ActivityThread.java:6669)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
** Activity (locals) Create, isFirst = true **
I never had an EditText on my main page. I tried to see if on my second activity I could initialize any EditText I have there, but all were added withe the designer. I looked at each view on second page to be sure that I didn't mistake a Label. I deleted everything on my main activity other then the button to switch activities I'm completely unsure why this happening when I push the button. Please help.
 

Attachments

  • cccnch.zip
    13 KB · Views: 297

kisoft

Well-Known Member
Licensed User
Longtime User
HI
I don't know if it's the right solution for the element to overlap in the view. In addition, it is like this:
B4X:
AssignF
    If edtlof.Text = 1 And edtnumf.Text = s1 Then
        lblmath1a = f1
    End If
    If edtlof.Text = 1 And edtnumf.Text = s2 Then
        lblmath1a = f2
    End If
    If edtlof.Text = 1 And edtnumf.Text = s3 Then
        lblmath1a = f3
    End If

It should look like this
B4X:
Sub AssignF
    If edtlof.Text = 1 And edtnumf.Text = s1 Then
        lblmath1a.Text = f1
    End If
    If edtlof.Text = 1 And edtnumf.Text = s2 Then
        lblmath1a.Text = f2
    End If
    If edtlof.Text = 1 And edtnumf.Text = s3 Then
        lblmath1a.Text = f3
 
Upvote 0
1. This:
B4X:
StartActivity("locals")
Should be:
B4X:
StartActivity(locals)
2. The Globals sub should only be used to declare variables and optionally assign values.
Invalid code in Globals:
B4X:
s1 = 24 - edtnumf.Text

thanks Erel i am curious when it comes to this though....
B4X:
s1 = 24 - edtnumf.Text
do you mean it's in the wrong place or structured wrong?
if the latter, how should that be structured?
 
Last edited:
Upvote 0

kisoft

Well-Known Member
Licensed User
Longtime User
You really don't see the difference between these ?....("locals") (locals)
In the latter case, you perform action on different types of variables.
 
Last edited:
Upvote 0
You really don't see the difference between these ?....("locals") (locals)
In the latter case, you perform action on different types of variables.
i wasn't asking the difference between those? i do see the difference... in the updated upload I corrected that...
I was asking about the structure of the var. It may be worded in a way that doesn't convey what i meant. I edited it.
 
Upvote 0
Top