Android Question How to change all buttons' text at the same time?

Binary Soft

Member
Licensed User
Longtime User
Hi,
I am a new basic4android user.

1. I created 10 buttons and text (1 to 10)
2. I also created a sub to disable all button at the same time

My Question is:
I want to create a sub that changes All Buttons's text from eg (1 to 10) to (5 to 14) at the same time.
( when I click another button eg btnText , all 1 to 10 buttons must change to 5,6,.. 14. )
Any Suggestion?

My code for 1 and 3 is:

Sub Activity_Create(FirstTime AsBoolean)
'1 create 10 buttons
For i = 0 To 9
Dim Btn AsButton
Btn.Initialize("Btn")
Btn.Text= i+1
Activity.AddView(Btn, 10dip, 10dip + 60dip * i, 200dip, 50dip)
Next
End Sub

Sub DisableAllButtons
'2 disable all button at the same time
For i = 0 To Activity.NumberOfViews - 1
Dim v As View
v = Activity.GetView(i)
If v Is Button Then 'check whether it is a Button
v.Enabled = False
End If
Next
End Sub
 

James Chamblin

Active Member
Licensed User
Longtime User
Create a Sub similar to DisableAllButtons. Replace v.Enabled with v.Text = v.Text + 4. If you have buttons which are not numbered, you might want to tag the relevant buttons when you create them, something like Btn.Tag = "Number", then in the if/then statement, you would do If v Is Button and v.Tag = "Number" then
 
Upvote 0
Top