B4A Library StdActionBar - Another ActionBar library

romario87027

Active Member
Licensed User
Longtime User
Compiling code. Error
'System.OutOfMemoryException'.
Following the example downloaded ActionBar.b4a .. while complie error
 

Erel

B4X founder
Staff member
Licensed User
Longtime User


Relevant code:
B4X:
Sub Globals
  Dim mFragment As MapFragment
  Dim gmap As GoogleMap
  Dim MapPanel As Panel
   Dim bar As StdActionBar
   Dim vp As StdViewPager
End Sub

Sub Activity_Create(FirstTime As Boolean)
  MapPanel.Initialize("")
   bar.Initialize("bar")
   bar.NavigationMode = bar.NAVIGATION_MODE_TABS
   bar.AddTab("Map")
   bar.AddTab("Red panel")
   Dim h As Int = CalculateHeight(True, False)
 
   vp.Initialize("vp", 2, 100%x, h)
   MapPanel.Initialize("")
  Activity.AddView(vp.AsView, 0, 0, 100%x, h)
   vp.Panels(0).AddView(MapPanel,0, 0, 100%x, h)
   vp.Panels(1).Color = Colors.Red
  If mFragment.IsGooglePlayServicesAvailable = False Then
  ToastMessageShow("Google Play services not available.", True)
  Else
  mFragment.Initialize("Map", MapPanel)
  End If
End Sub

Sub CalculateHeight (TabsMode As Boolean, SplitEnabled As Boolean) As Int
   If 100%x >= 480dip Then
     Return 100%y
   Else
     Dim fix As Int
     If TabsMode Then fix = 48dip
     If SplitEnabled Then fix = fix + 48dip
     Return 100%y - fix
   End If
End Sub

Sub VP_PageSelected (Position As Int)
   If bar.SelectedIndex <> Position Then bar.SelectedIndex = Position
End Sub

Sub bar_TabChanged(Index As Int, STab As StdTab)
   If vp.currentPage <> Index Then   vp.ScrollTo(Index, False)
End Sub
 

Attachments

  • StdActionBar.zip
    12.4 KB · Views: 290
Last edited:

Augustinas Impalis

Member
Licensed User
Longtime User


Thank you so much Erel!!
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Hello,
is it possible to use this library without including Title?
 

figorra

Member
Licensed User
Longtime User
Hi, I have this error on my code... when run.....

B4X:
Parsing code.                          0.00
Compiling code.                        0.02
Compiling layouts code.                0.01
Generating R file.                      0.06
Compiling generated Java code.          Error
javac 1.6.0_45
src\b4a\example\main.java:268: cannot find symbol
symbol  : class StdActionBar
location: package anywheresoftware.b4a.objects
public anywheresoftware.b4a.objects.StdActionBar _bar = null;
                                  ^
1 error
I have de example and the lib......

Can you help me please?
 

jcesar

Active Member
Licensed User
Longtime User
Thanks Erel

it works.



But, is there a way to customize this action view, i need to change some properties like font color, background color, top, fixed width and left position.

I need something like this:



This second was created with another tool, and is not a native action bar, its something like a panel with views in b4a.
 

jcesar

Active Member
Licensed User
Longtime User
Have you tried to change the view properties?
Yes

I set up the properties :

B4X:
dim edtTeste as EditText
edtTeste.Initialize("")
edtTeste.Width = 100dip
edtTeste.Hint = "Search !"
edtTeste.TextColor = Colors.White
Dim jo As JavaObject = actionBar
jo = jo.GetField("bar")
jo.RunMethod("setDisplayShowCustomEnabled", ArrayAsObject(true))
jo.RunMethod("setCustomView", ArrayAsObject(edtTeste))

But when i try setup the width or left position i get a java.lang.NullPointerException
 

Dario126

Member
Licensed User
Longtime User
As pointed out, it's only supported by Android 4+.

Can't you (possibly through 'support' library) make it available down to 3+ ?

I'we seen 'StdActionBarHelper' by corwin42, but using that is one more brick on top of another, and usually i'm avoiding that if possible.
 

palmzac

Active Member
Licensed User
Longtime User
Hi Erel,

It's Great library. Where is the detail document ? ( like URL )

How to detect the click event of ic_small.png ? Thanks !
 
Last edited:

corwin42

Expert
Licensed User
Longtime User

I managed to use ActionBarCompat from the support library with B4A. It works with some tricks (like modifying the generated Java code in #CustomBuildActions etc.) but it is quite complicated to use and it's a really dirty hack.

I can understand Erel that he (currently) don't want to add support for it because it would make the ActionBar feature quite complicated to use (like adding resource files etc.) and it will need differently generated java code depending on weather ActionBarCompat is used or not. And with a dropping userbase of less than 20% it may be not worth the effort.

Before you ask. Sorry, I won't make my solution public because every new version of B4A may break it totally and I can't do the support for such a dangerous hack.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…