What am I doing wrong? The text is not updating. I checked it and it returns the text I want it to it just isn't changing the text of the button.
btngameplay.Initialize("")
btngameplay.Text = "Team " & SQL1.ExecQuerySingleResult("SELECT distinct teamname FROM tblTeamNames tn join tblgamesettings gs on tn.gameid = gs.id where tn.id = 1") & " start"
I suppose that btngameplay is defined in a layout file.
If yes, you must delete btngameplay.Initialize("").
When you load a layout file all views are automatically initialized.
If not you must add the button on the Activity or a Panel.
It is giving me the error that the button needs to be initilized first. Here is my code.
Sub rbtNameTeamNo_CheckedChange(Checked As Boolean)
If lblNumberOfteams.Text = "Play Bonus round?" Then
SQL1.ExecNonQuery("Update tblGameSettings set BonusRound = 'NO'")
BonusRound = "NO"
rbtNameTeamNo.Checked = False
lblNumberOfteams.Text = "Save settings?"
rbtNameTeamYes.Text = "Yes"
rbtNameTeamNo.Text = "No"
rbtNameTeamYes.Visible = True
rbtNameTeamNo.Visible = True
lblNumberOfteams.Visible = True
Else
If lblNumberOfteams.Text = "Save settings?" Then
Activity.LoadLayout("lytGamePlay")
'Msgbox(SQL1.ExecQuerySingleResult("SELECT distinct teamname FROM tblTeamNames tn join tblgamesettings gs on tn.gameid = gs.id where tn.id = 1"),"TEST")
If SQL1.ExecQuerySingleResult("SELECT count(gamename) FROM tblGameSettings where gamename is null") = 0 Then
SQL1.ExecNonQuery("Update tblGameSettings set gamename = 'DEFAULT' where gamename is null")
SQL1.ExecNonQuery("Update tblTeamNames set gameid = " & SQL1.ExecQuerySingleResult("SELECT id FROM tblGameSettings where gamename = 'DEFAULT'") & "")
'btngameplay.Initialize("")
Activity.LoadLayout("lytGamePlay")
btngameplay.Text = "Team " & SQL1.ExecQuerySingleResult("SELECT distinct teamname FROM tblTeamNames tn join tblgamesettings gs on tn.gameid = gs.id where tn.id = 1") & " start"
Anyway, if you have loaded another layout before, use Activity.RemoveAllViews, before loading lyGamePlay.
Note that the views of lyGamePlay should be declared in Globals.
Still isn't working. Here is the code. The msgbox works. If I don't initialize the button it gives me an error stating I need to initialize the button.
Activity.RemoveAllViews
Activity.LoadLayout("lytGamePlay")
btngameplay.Initialize("")
btngameplay.Text = "Team " & SQL1.ExecQuerySingleResult("SELECT distinct teamname FROM tblTeamNames tn join tblgamesettings gs on tn.gameid = gs.id where tn.id = 1") & " start"
Msgbox("Team " & SQL1.ExecQuerySingleResult("SELECT distinct teamname FROM tblTeamNames tn join tblgamesettings gs on tn.gameid = gs.id where tn.id = 1") & " start","test")
End If
btngameplay can be created (added to an Activity or Panel) by code (only in this case you must inizialize it by code) or by Designer (in this case you do not have to initialize it).
In both cases you must declare it (globals).
Damn. You were right. I had it named wrong. Question. In the designer. I added the button then tried to generate members but it didn't do it. Why would that be?
Damn. You were right. I had it named wrong. Question. In the designer. I added the button then tried to generate members but it didn't do it. Why would that be?