可以用代码直接创建,但是摆放位置比较麻烦,我是一个比较懒的人。。。
首先,把需要的控件在设计器中摆放好
这里面以单选框RadioButton为例
如图:
将所有RadioButton的Tag属性并将其设置为1
然后构建控件数组,代码如下:
Sub Globals
Dim RadioButtons() As RadioButton
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout1")
RadioButtons=CollectViews("1")
End Sub
Sub CollectViews(Tag As String) As RadioButton()
Dim RadioButtonsList As List
RadioButtonsList.Initialize
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag = Tag Then RadioButtonsList.Add(v)
Next
Dim rbts(RadioButtonsList.Size) As RadioButton
For i = 0 To rbts.Length - 1
Dim rbt As Label = RadioButtonsList.Get(i)
rbts(i) = rbt
Next
Return rbts
End Sub