Please find below the code snippet and guide me if I am missing something here-
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private pnlHome As Panel
Private ImageView1 As ImageView
Private pnlLighting As Panel
Private pnlMain As Panel
Private pnlTempControl As Panel
Private pnlTopBar As Panel
Private ImageView2 As ImageView
Private pnlTVControl As Panel
Private pnlSTB As Panel
Private btnRoom1 As Button
Private pnlEntertainment As Panel
Private btnEntertainment As Button
Private btnLightingControl As Button
Private btnTempControl As Button
Private btnSecurity As Button
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("Room_Change")
Activity.LoadLayout("Main")
pnlHome.LoadLayout("Home")
pnlLighting.LoadLayout("Lighting")
pnlTempControl.LoadLayout("Temperature_Control")
pnlEntertainment.LoadLayout("Entertainment")
pnlMain.Visible=True
ImageView2.Visible=True
pnlHome.Visible=False
pnlLighting.Visible=False
pnlTempControl.Visible=False
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
ExitApplication
End Sub
Sub btnRoom1_Click
'Activity.LoadLayout("Home")
pnlHome.LoadLayout("Home")
btnLightingControl.SetBackgroundImage(LoadBitmap(File.DirAssets,"lighting.png"))
btnTempControl.SetBackgroundImage(LoadBitmap(File.DirAssets,"temp.png"))
btnEntertainment.SetBackgroundImage(LoadBitmap(File.DirAssets,"music-entertainment-psd-icon.png"))
btnSecurity.SetBackgroundImage(LoadBitmap(File.DirAssets,"security.png"))
pnlHome.Visible=True
pnlMain.Visible=False
pnlLighting.Visible=False
pnlTempControl.Visible=False
pnlEntertainment.Visible=False
End Sub
Sub btnEntertainment_Click
pnlEntertainment.LoadLayout("Entertainment")
pnlEntertainment.Visible=True
pnlMain.Visible=False
pnlHome.Visible=False
pnlLighting.Visible=False
pnlTempControl.Visible=False
End Sub