B4A Library [Class] ActionBar

Douglas Farias

Expert
Licensed User
Longtime User
i m upgraded my android to 4.3.3 too and i m using this class no problem
moto g
 

Informatix

Expert
Licensed User
Longtime User
i m upgraded my android to 4.3.3 too and i m using this class no problem
moto g
I just read french articles on this new version and it seems there are a few issues introduced with it, so they recommend to not upgrade for now (e.g. this link in english). That explains maybe why I didn't receive any proposal of update from Google for my Nexus 7 (usually Nexus devices are the first to be upgraded).
 

inakigarm

Well-Known Member
Licensed User
Longtime User
Hi:

I'd try to use your great class but I've a problem when I've begin to test it; Taking your demo on ActionBar (v1.43), with B4A 3.82 and Reflection lib (2.4), when I change the code of an actionbar button from Long_Click to Click, the behavior seems the same as with LongClick (need a long time click to show the toastMessage)

Is this normal actionbar behavior ??

PD: only change this
B4X:
actbar1.AddButton(LoadBitmap(File.DirAssets, "refresh.png"), "", 5, -1, "", "Refresh_Click")

Sub Refresh_Click(ActionBar As ClsActionBar, Btn As View)
    ToastMessageShow("Refresh", False)
End Sub
 

Informatix

Expert
Licensed User
Longtime User
You just changed the name of the event. Nothing more. If you want to receive a different event, move the last parameter in AddButton or add a parameter for Click events.
 

shasunder

Member
Licensed User
Longtime User
Hi

Let us assume that i have 3 buttons in Actionbar. How to click the button programatically. I know it can be achieved by using Reflection. Could some one shed light to me please...

lasttab = AB.AddButton(LoadBitmap(File.DirAssets, "tab_selected.png"), "Home", 5, 1, "Home_Click", "Home_LongClick")
AB.SetIconAsWideAsText(True)
AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Favorite", 5, 2, "Star_Click", "Star_LongClick")
AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Share", 5, 3, "Share_Click", "Share_LongClick")


Sub Home_Click(ActionBar As ClsActionBar, btn As View)
If lasttab.IsInitialized Then
AB.ReplaceIcon(lasttab, LoadBitmap(File.DirAssets, "tab_normal.png"))
End If
AB.ReplaceIcon(btn, LoadBitmap(File.DirAssets, "tab_selected.png"))
lasttab = btn

Sub Share_Click(ActionBar As ClsActionBar, btn As View)
If lasttab.IsInitialized Then
AB.ReplaceIcon(lasttab, LoadBitmap(File.DirAssets, "tab_normal.png"))
End If
AB.ReplaceIcon(btn, LoadBitmap(File.DirAssets, "tab_selected.png"))
lasttab = btn

Sub Refresh_Click(ActionBar As ClsActionBar, btn As View)
If lasttab.IsInitialized Then
AB.ReplaceIcon(lasttab, LoadBitmap(File.DirAssets, "tab_normal.png"))
End If
AB.ReplaceIcon(btn, LoadBitmap(File.DirAssets, "tab_selected.png"))
lasttab = btn
 

shasunder

Member
Licensed User
Longtime User
To click a button programatically, just call its Click sub (...or I don't understand the question).
Thanks Informatix.

If it is
Sub btn_new()

then calling btn_new will work. But for this case

Share_Click(ActionBar As ClsActionBar, btn As View)

if I call share_click I get the below error

B4A version 4.30
Parsing code. 0.06
Compiling code. Error
Error compiling program.
Error description: Syntax error (missing parameter).
Occurred on line: 143
Share_Click
Word: share_click
 

Informatix

Expert
Licensed User
Longtime User
Your error is explicitely given: Syntax error (missing parameter).
You forgot to pass parameters to the function.
 

shasunder

Member
Licensed User
Longtime User
Your error is explicitely given: Syntax error (missing parameter).
You forgot to pass parameters to the function.
That is where I am having problem with. Dont know how to pass the parameters for action bar and button.My action bar is defined as "AB".
Some how I solved it by other work around. But Still interested to know how to programatically click.
 

Informatix

Expert
Licensed User
Longtime User
That is where I am having problem with. Dont know how to pass the parameters for action bar and button.My action bar is defined as "AB".
Some how I solved it by other work around. But Still interested to know how to programatically click.
??? The function has two parameters: ActionBar As ClsActionBar, btn As View. Then pass the action bar (AB) and the button. Where's the difficulty ?
 

shasunder

Member
Licensed User
Longtime User
??? The function has two parameters: ActionBar As ClsActionBar, btn As View. Then pass the action bar (AB) and the button. Where's the difficulty ?
Thanks informatix. Your thought helped me. This is how it worked.

homebtn = AB.AddButton(LoadBitmap(File.DirAssets, "tab_selected.png"), "Home", 5, 1, "Home_Click", "Home_LongClick")
AB.SetIconAsWideAsText(True)
If FirstTime=True Then lasttab =homebtn
favbtn= AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Favorite", 5, 2, "Star_Click", "Star_LongClick")
sharebtn =AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "Share", 5, 3, "Share_Click", "Share_LongClick")
refbtn =AB.AddButton(LoadBitmap(File.DirAssets, "tab_normal.png"), "About", 5, 4, "Refresh_Click", "Refresh_LongClick")

and calling

Star_Click(AB,favbtn)

worked. Thanks. Thanks again.
 

BarryW

Active Member
Licensed User
Longtime User
I love this...

Is there any animated transition when button is remove or icon is replaced? Just an idea. Tnx...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…