Android Question ACTION BAR - CHANGE ICON, COLORS, TEXT BY CODE

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi
i want to add a user theme selector in my app, for example i need Blue, Green, Red, Purple...
For this i need to change in B4A code some attributes of action bar and it's elements, but i don't know how to

Now i do the following code in B4XPage_Appear
B4X:
    ' Set Title of page
    ' with a specific Textcolor  -- don't require manifest and it's fine form me
    Dim cs                         As CSBuilder
    Dim ThemeTextColor         As Int 
    Dim ActionBarCaption     As String 
    ThemeTextColor             = xui.Color_White
    ActionBarCaption            = "Home"
    cs.Initialize.Size(22).Color(ThemeTextColor).Append(ActionBarCaption).PopAll

    B4XPages.SetTitle(Me,cs)    
     
     ' Set BackGround of ActionBar  -- without manifest... 
     'Work fine in B4a  but Don't know if is right on B4I
    Dim cd As ColorDrawable 
    cd.Initialize(xui.Color_RGB(0,93,192),0)
    B4XPages.GetManager.ActionBar.RunMethod("setStackedBackgroundDrawable", Array(cd))
    

     'Set HomeIcon of ActionBar  -- without manifest... 
    'Work fine in B4a  but Don't know if is right on B4I

    Dim bd As BitmapDrawable
    bd.Initialize(LoadBitmap(File.DirAssets,"myGoHomeIcon.png"))
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayHomeAsUpEnabled", Array(True))
    B4XPages.GetManager.ActionBar.RunMethod("setHomeAsUpIndicator", Array(bd))
    
    
     'Set HomeIcon of ActionBar  -- without manifest... 
    'Work fine in B4a  but Don't know if is right on B4
    'Force visibility of goHome Icon
    B4XPages.GetManager.ActionBar.RunMethod("setDisplayShowHomeEnabled", Array(True))


to complete my request i have 2 question :
1) how to change the menuIcon Bitmap or MenuIcon color by code
2) if the code that i have posted working in b4I also

thank's
 

Gianni Sassanelli

Active Member
Licensed User
Longtime User
setColorFilter return error

java.lang.RuntimeException: Method: setColorFilter not found in: com.android.internal.app.WindowDecorActionBar
 
Upvote 0

Gianni Sassanelli

Active Member
Licensed User
Longtime User
Hi Erel, first of all thank you for your precious help.
I am trying to use the B4XPage mode for development of my app but I am finding different difficulties compared to the old mode
Certainly due to my gaps in knowledgebase.
For ActionBar, to overcome some Android limits I used in past Fullscreen with noTitle mode in my activities.
Each one of it contain on the top a panel in witch I put all i need and drive as I like best.
With the pages I seem to have understood that the use in fullscreen is not recommended and therefore I am trying to manage the action bar with all the problems encountered.
Today i found another that concerns the textColorPrimary attribute inserted in the Manifest to change the colors of the objects in the ActionBar.
This work fine for ActionBar but changes the foreground color for many views of the whole app.
For example the text of the msgbox also turns white, but for this I am opening a new Thread
 
Upvote 0
Top