B4A Library [Class] ActionBar

Adilson Jacinto

Active Member
Licensed User
You have a demo, you have the source code of the class, you have the solution. And you want me to write your code? You're kidding?
No, I don't want you to write the code I just wanted to point me out in the write direction.
I have done what you asked me to do but it does not work.
I created 4 global variables for this.
B4X:
    Dim btn_home As View
    Dim btn_qlist As View
    Dim btn_appinfo As View
    Dim btn_settings As View
Then in activity create I have the following

B4X:
btn_home = AB.AddButton(LoadBitmap(File.DirAssets, "home.png"), "", 2, 1, "Home_Click", "")
    AB.SetText(btn_home, "Home", Colors.Yellow, -1)
    btn_qlist = AB.AddButton(LoadBitmap(File.DirAssets, "listQ.png"), "Q-List", 2, 2, "QueueList_Click", "")
    btn_appinfo = AB.AddButton(LoadBitmap(File.DirAssets, "info.png"), "App Info", 2, 3, "Info_Click", "")
    btn_settings = AB.AddButton(LoadBitmap(File.DirAssets, "rsettings.png"), "Settings", 2, 4, "Settings_Click", "")
Then in the button clcick
B4X:
Sub Home_Click(ActionBar As ClsActionBar, Btn As View)
  
    ' We remove everything from the action bar before displaying a new style

    AB.SetText(btn_home, "Home", Colors.Yellow, -1)
    AB.SetText(btn_qlist, "Q-List", Colors.White, -1)
    AB.SetText(btn_settings, "Settings", Colors.White, -1)

  
End Sub
And I do the above for the other buttons and it does not work @Informatix !!!


@Informatix I think it does not like colors.white because I tried different collors and it worked. So what is the default color for white?
 
Last edited:

Informatix

Expert
Licensed User
No, I don't want you to write the code I just wanted to point me out in the write direction.
I have done what you asked me to do but it does not work.
I created 4 global variables for this.
B4X:
    Dim btn_home As View
    Dim btn_qlist As View
    Dim btn_appinfo As View
    Dim btn_settings As View
Then in activity create I have the following

B4X:
btn_home = AB.AddButton(LoadBitmap(File.DirAssets, "home.png"), "", 2, 1, "Home_Click", "")
    AB.SetText(btn_home, "Home", Colors.Yellow, -1)
    btn_qlist = AB.AddButton(LoadBitmap(File.DirAssets, "listQ.png"), "Q-List", 2, 2, "QueueList_Click", "")
    btn_appinfo = AB.AddButton(LoadBitmap(File.DirAssets, "info.png"), "App Info", 2, 3, "Info_Click", "")
    btn_settings = AB.AddButton(LoadBitmap(File.DirAssets, "rsettings.png"), "Settings", 2, 4, "Settings_Click", "")
Then in the button clcick
B4X:
Sub Home_Click(ActionBar As ClsActionBar, Btn As View)
 
    ' We remove everything from the action bar before displaying a new style

    AB.SetText(btn_home, "Home", Colors.Yellow, -1)
    AB.SetText(btn_qlist, "Q-List", Colors.White, -1)
    AB.SetText(btn_settings, "Settings", Colors.White, -1)

 
End Sub
And I do the above for the other buttons and it does not work @Informatix !!!


@Informatix I think it does not like colors.white because I tried different collors and it worked. So what is the default color for white?
Your code should work.

If I do these changes to the demo:
- I add "Dim BtnFavorite As View" to Globals
- I add "BtnFavorite=" before "AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Favorite", 5, 2, "Tab_Click", "Star_LongClick")"
- I add "AB.SetText(BtnFavorite, "Favorite", Colors.Blue, -1)" in Tab_Click(...)
Then the Favorite word becomes blue when I click on any tab (with the Tab style).
 

Adilson Jacinto

Active Member
Licensed User
Your code should work.

If I do these changes to the demo:
- I add "Dim BtnFavorite As View" to Globals
- I add "BtnFavorite=" before "AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Favorite", 5, 2, "Tab_Click", "Star_LongClick")"
- I add "AB.SetText(BtnFavorite, "Favorite", Colors.Blue, -1)" in Tab_Click(...)
Then the Favorite word becomes blue when I click on any tab (with the Tab style).

As I edited my previous post, it works with any color apart from colors.white, I cannot put it back to the default color
 

Informatix

Expert
Licensed User
As I edited my previous post, it works with any color apart from colors.white, I cannot put it back to the default color
Because Colors.White = -1. I didn't notice it when I did the class. If you set the color to Colors.RGB(254,254,254), the result will be visually white but the value of the color will be different from -1.
 

ma7tin

Member
Licensed User
Hi, how to make working 3 dot menu on the right side of ClsActionBar like a other menus from other packages ? Please help ..
 
Top