Android Question [SOLVED] New B4A user

malcolmfowler

Member
Licensed User
Longtime User
I have just started using B4A (paid version) and having trouble with my first program. I have followed the tutorial but I am getting the following error when trying to validate the customerName editText field in sub btnSave_click

Line 37 is the line after the sub btnSave_Click

I used the designer to draw the screen and editText fields.

Thanks
Malcolm


** Activity (newcustomer) Pause, UserClosed = true **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (newcustomer) Create, isFirst = true **
** Activity (newcustomer) Resume **
Error occurred on line: 37 (newCustomer)
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 b4a.example.newcustomer._btnsave_click(newcustomer.java:388)
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 anywheresoftware.b4a.BA.raiseEvent2(BA.java:180)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5207)
at android.view.View$PerformClick.run(View.java:21168)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5443)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)



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.

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 customerName As EditText
    Private emailAddress As EditText
    Private mobilePhone As EditText
    Private Label1 As Label
    Private btnSave As Button
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("layoutNewCustomer.bal")
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub btnSave_Click
    If customerName.Text = "" Then
        MsgboxAsync("Customer name required","")
    End If
End Sub
 

Computersmith64

Well-Known Member
Licensed User
Longtime User
Check the spelling of the view name in the layout. If that looks good, post the whole project (use File->Export as zip in the IDE, then upload the zip file).

- Colin.
 
Upvote 0

malcolmfowler

Member
Licensed User
Longtime User
... sorry all, my own fault. I have been trying different screen designs and deleted the editText of that name. Please ignore my post.
 
Upvote 0

Computersmith64

Well-Known Member
Licensed User
Longtime User
Just edit the thread title & add a "[SOLVED]" at the front if you can. Also for future posts, it's good if you can be a bit more specific in the thread title - eg: "EditText Initialization Error" (or something) as opposed to "New B4A user". It just helps others to recognize threads they may be able to assist with more quickly.

Glad you got it sorted.

- Colin.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…