B4A Library StdActionBar - Another ActionBar library

Discussion in 'Additional libraries, classes and official updates' started by Erel, Jan 16, 2014.

  1. Wembly

    Wembly Member Licensed User

    Yes all working - Thanks for the info.
     
  2. romario87027

    romario87027 Member Licensed User

    Compiling code. Error
    'System.OutOfMemoryException'.
    Following the example downloaded ActionBar.b4a .. while complie error
     
  3. romario87027

    romario87027 Member Licensed User

    Resolved by updating the version 3.20 B4A
     
  4. Augustinas Impalis

    Augustinas Impalis Member Licensed User

    @Erel How would I assign Google Maps from this turorial to a specific tab? I keep trying but it keeps displaying the map across all the tabs. thank you
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    upload_2014-2-16_10-3-38.png

    Relevant code:
    Code:
    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(TrueFalse)
     
       vp.Initialize(
    "vp"2100%x, h)
       MapPanel.Initialize(
    "")
      
    Activity.AddView(vp.AsView, 00100%x, h)
       vp.Panels(
    0).AddView(MapPanel,00100%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
     

    Attached Files:

    Last edited: Mar 20, 2018
    arjuna83 likes this.
  6. Augustinas Impalis

    Augustinas Impalis Member Licensed User


    Thank you so much Erel!!
     
  7. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    Hello,
    is it possible to use this library without including Title?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The action bar will be removed together with the title. However you can still use StdViewPager to switch between pages.
     
  9. imgsimonebiliato

    imgsimonebiliato Well-Known Member Licensed User

    Perfect!
     
  10. figorra

    figorra Member Licensed User

    Hi, I have this error on my code... when run.....

    Code:
    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?
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    Are you sure that you copied the xml and jar files to the correct location?
     
  12. jcesar

    jcesar Active Member Licensed User

  13. Erel

    Erel Administrator Staff Member Licensed User

    Try this:
    Code:
    Dim jo As JavaObject = ActionBar1
    jo = jo.GetField(
    "bar")
    jo.RunMethod(
    "setDisplayShowCustomEnabled"Array As Object(true))
    jo.RunMethod(
    "setCustomView"Array As Object(<ViewYouWantToAdd>))
     
    shashkiranr and jcesar like this.
  14. jcesar

    jcesar Active Member Licensed User

    Thanks Erel

    it works.

    [​IMG]

    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:

    [​IMG]

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

    Erel Administrator Staff Member Licensed User

    Have you tried to change the view properties?
     
  16. jcesar

    jcesar Active Member Licensed User

    Yes

    I set up the properties :

    Code:
    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
     
  17. Dario126

    Dario126 Member Licensed 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.
     
  18. Erel

    Erel Administrator Staff Member Licensed User

    @jcesar try to add the EditText to a Panel and then add the panel as the custom view. Now try to set the EditText width.
     
  19. palmzac

    palmzac Active Member Licensed 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: Mar 4, 2014
  20. corwin42

    corwin42 Expert Licensed 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.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice