Android Question Tutorial: First UI Program

Shelby

Well-Known Member
Licensed User
Longtime User
I continually have problems using my B4A program following Erel's tutorials which use B4J. Now I'm getting started with the First_UI_Program. I don't know how to deal with finding something in a library so I can satisfy the suggestion in the error below about missing a library reference.
My B4A program gives an error message:
B4A Version: 7.80
Parsing code. Error
Error parsing program.
Error description: Unknown type: jfx
Are you missing a library reference?
Error occurred on line: 4 (Main)
Private fx As JFX

Please help.
Thanks

My code:
B4X:
Sub Process_Globals 
Private fx As JFX      line4
    Private MainForm As Form
    Private ChosenNumber As Int
    Private txtNumber As TextField
    Private lblMessage As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
    MainForm = Form1
    Log(txtNumber.IsInitialized)
    MainForm.RootPane.LoadLayout("Layout1") 
    Log(txtNumber.IsInitialized)
    MainForm.Show
    ChosenNumber = Rnd(1, 101)
End Sub
Sub btnGuess_Click
    Dim UserNumber As Int = txtNumber.Text
    If UserNumber > ChosenNumber Then
        lblMessage.Text = "My number is smaller"
    Else lblMessage.Text = " My number is larger"
    Else
        lblMessage.Text = "Well Done !!!"
    End If
   
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
 

mcqueccu

Well-Known Member
Licensed User
Longtime User
Also these are also for B4J Remove them too.

B4X:
MainForm = Form1
Log(txtNumber.IsInitialized)
MainForm.RootPane.LoadLayout("Layout1")
Log(txtNumber.IsInitialized)
MainForm.Show

You will have to goto Designer and create a new layout with B4A.
Find the B4A Equivalent example attached


B4X:
#Region  Project Attributes
    #ApplicationLabel: B4A Example
    #VersionCode: 1
    #VersionName:
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#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 btnGuess As Button
    Private edtNumber As EditText
    Private lblMessage As Label
    Dim ChosenNumber As Int
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("Layout1")   
    ChosenNumber = Rnd(1, 101)   
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub btnGuess_Click
    Dim UserNumber As Int = edtNumber.Text
    
    If UserNumber > ChosenNumber Then
        lblMessage.Text = "My number is smaller"
    Else if UserNumber < ChosenNumber Then
         lblMessage.Text = " My number is larger"
    Else
        lblMessage.Text = "Well Done !!!"
    End If
  
End Sub
 

Attachments

  • FirstUiExample.zip
    3.5 KB · Views: 324
Upvote 0

Shelby

Well-Known Member
Licensed User
Longtime User
Thanks again mcqueccu; you're so kind to take the time to help me.
 
Last edited:
Upvote 0
Top