B4A Button(按钮)、Label(标签)、Panel(分组)控件的简单使用
一个简单的Demo,运行 B4A 开发环境,在可视化设计器里拖入Button(按钮)、Label(标签)、Panel(分组)控件,按照喜欢的布局调整好并保存为From1:在活动窗口创建时加载 Form1,在 Button1 按钮的 Click 事件里让标签文本等于"大家好!这是第一个 B4A Android Demo" ,代码如下:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Label1 As Label
Private Button1 As Button
Private Panel1 As Panel
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")
Activity.LoadLayout("Form1") '读取 Form1 窗口的控件布局到活动视窗
End Sub
'按钮事件
Sub Button1_Click
Label1.Text="大家好!这是第一个 B4A Android Demo"
End Sub
运行结果:
页:
[1]