I am trying to hide a button and display a label in its place depending on whether a record exists in a SQLite table.
My Activity has the button and label added to it in the Designer.
This is my code:
This seems to have no effect on the button or the label.
Any ideas where I am going wrong?
My Activity has the button and label added to it in the Designer.
This is my code:
B4X:
Sub Globals
Dim btnGetRunSheet As Button
Dim lblSelectedRoute As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
If FirstTime Then
If File.Exists(SQLDataBasePath, SQLDateBaseName) = False Then
'if not, initialize it
SQLLite.Initialize(SQLDataBasePath, SQLDateBaseName, True)
'and create it
CreateDataBase
Else
'if yes, initialize it
SQLLite.Initialize(SQLDataBasePath, SQLDateBaseName, True)
End If
End If
HideGetRunSheet
Activity.LoadLayout("MainMenu")
End Sub
Sub Activity_Resume
HideGetRunSheet
End Sub
Sub HideGetRunSheet
Dim Query As String
Dim curSelectedRoute As Cursor
Query = "SELECT srt_name FROM SelectedRoute"
curSelectedRoute = SQLLite.ExecQuery(Query)
curSelectedRoute.Position = 0
btnGetRunSheet.Initialize("btnGetRunSheet")
lblSelectedRoute.Initialize("lblSelectedRoute")
If curSelectedRoute.RowCount > 0 Then
btnGetRunSheet.Visible = False
lblSelectedRoute.Text = curSelectedRoute.GetString("srt_name")
lblSelectedRoute.Visible = True
Else
btnGetRunSheet.Visible = True
lblSelectedRoute.Visible = False
End If
End Sub
This seems to have no effect on the button or the label.
Any ideas where I am going wrong?