College of Computing Studies
Basic4Android (currently known as B4A) is a rapid application development tool for native
Android applications, developed and marketed by Anywhere Software Ltd.
B4A is an alternative to programming with Java.
B4A includes a visual designer that simplifies the process of building user interfaces that target
phones and tablets with different screen sizes. Compiled programs can be tested in AVD
Manager emulators or on real Android devices using Android Debug Bridge and B4A Bridge.
The language itself is similar to Visual Basic and Visual Basic .Net though it is adapted to the
native Android environment. B4A is an object-based and event-driven language.
B4A Environment
JBQ@2021
College of Computing Studies
B4A Designer
B4A Output
JBQ@2021
College of Computing Studies
Label
A label is a graphical control used to display text.
1. Open B4A and then click File New Default. Type the project name and click Ok.
JBQ@2021
College of Computing Studies
2. Click Designer Open Designer. A visual designer will appear with a button already
placed in the designer. Click and delete the button.
JBQ@2021
College of Computing Studies
3. Click Add View Label. A Label1 will appear on the designer.
4. Click Label1 then go to the Properties and change the Text into “Hello World!”
JBQ@2021
College of Computing Studies
5. Go back to Main Module and press the Run button.
6. Sample Output
JBQ@2021
College of Computing Studies
7. Click Stop button to go back in Main program.
JBQ@2021
College of Computing Studies
Activity #2 – EditText
- A EditText control is used to display, or accept as input, a single line of text.
Click Add View EditText.
JBQ@2021
College of Computing Studies
You can modify the text style and select what input type you will going to use.
JBQ@2021
College of Computing Studies
Button
The Button control represents a standard Windows button. It is generally used to generate a
Click event by providing a handler for the Click event.
You can change the Name, Text, Styles, etc. in the Properties.
JBQ@2021
College of Computing Studies
Button Click Event and Msgbox
An event is a signal that informs an application that something important has occurred. For
example, when a user clicks a control on a form, the form can raise a Click event and call a
procedure that handles the event. Events also allow separate tasks to communicate.
Click Tools then click Generate Members
Expand btnclick(Button) then choose Click event then click Generate Members and then Close.
JBQ@2021
College of Computing Studies
Then go back in Main Module, there you will see that a Sub btnclick Event appeared where
codes will be typed inside this event.
Msgbox
JBQ@2021
College of Computing Studies
Output
Msgbox shows a modal message box with the specified message and title. The dialog will show
one OK button.
MsgboxAsync is recommended to use instead of msgbox because it is a non-modal message box.
Modal dialog boxes must close first before you can execute further actions with the
superordinate window. The file selection dialog box, for example, is a modal dialog box.
Non-modal dialog boxes can remain open while you work with the superordinate window.
JBQ@2021
College of Computing Studies
Prepared by:
Joel B. Quiambao
Instructor1
JBQ@2021
College of Computing Studies
JBQ@2021