Android Question How to change color on menu background?

Nb1320

Member
Licensed User
Longtime User
Hello All,
I am really hoping someone can help me and I can fix my issue quickly. I am using Animated Sliding Menu, if you need to know that. This is the code that populates the list, everything works and is completely functional. My problem is that each item make a panel visible. Each panel has 2 checkboxes attached to it. I want to make the check boxes determine the colors of the item background. For Example

B4X:
If Checkbox1.checked=True Then
MyMenu.AddItem(1, "  01", Colors.White, Colors.Green, 2)
Else If checkbox2.checked=True Then
MyMenu.AddItem(1, "  01", Colors.White, Colors.Red, 2)
Else MyMenu.AddItem(1, "  01", Colors.White, Colors.darkGray, 2)
End If

To me, this makes sense and should work, but the app only displays the original darkgray color.


B4X:
MyMenu.Initialize(Activity, Me, "Books Collection", "Test", "L", 30dip, 100%x, Colors.Transparent, Null)
    MyMenu.AddItem(icon, "List", Colors.White, Colors.Transparent, 1)
    MyMenu.AddItem(1, "  01", Colors.White, Colors.darkGray, 2)
    MyMenu.AddItem(2, "  02", Colors.White, Colors.Transparent, 3)
    MyMenu.AddItem(3, "  03", Colors.White, Colors.darkGray, 4)
    MyMenu.AddItem(4, "  03", Colors.White, Colors.Transparent, 5)
    MyMenu.AddItem(Null, "", Colors.White, Colors.Transparent, 6)
    MyMenu.SetTitle(Colors.Transparent, Colors.White, Gravity.CENTER_HORIZONTAL, Null)
    MyMenu.OpenMenu("Default")
  
End Sub

Sub Test_Click(SelectedItem As Object)
      
    If SelectedItem = 1 Then
        StartActivity(MyCollection)
    End If
    If SelectedItem = 2 Then
        1panel.Visible=True
    End If
     If SelectedItem = 3 Then
        2panel.Visible=True
    End If
    If SelectedItem = 4 Then
        3panel.Visible=True
    End If
    If SelectedItem = 5 Then
        4panel.Visible=True
    End If

I APPRECIATE ANY AND ALL HELP!! Thank you!
 
Last edited:

BTNorthrup

Member
Licensed User
Longtime User
You might be able to try:

B4X:
If Checkbox1.checked = True Then
MyMenu.AddItem(1, "  01", Colors.White, Colors.Green, 2)
Else If Checkbox2.checked = True Then
MyMenu.AddItem(1, "  01", Colors.White, Colors.Red, 2)
Else If Checkbox1.checked = False & Checkbox2.checked = False Then
MyMenu.AddItem(1, "  01", Colors.White, Colors.darkGray, 2)
End If


Edit: You may want this in there as well, assuming you want it to be gray when either both or neither of the boxes are checked.

Else If Checkbox1.checked = True & Checkbox2.checked = True Then
MyMenu.AddItem(1, " 01", Colors.White, Colors.darkGray, 2)
 
Last edited:
Upvote 0
Top