B4A Library StdActionBar - Another ActionBar library

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

  1. jcesar

    jcesar Active Member Licensed User

    I try, but nothing happens... The panel is not displayed in the actionbar. And if i set the EditText width i get the same NullPointerException error.

    I think must be something with layouts... But I dont know if its possible solve with b4a.
     
  2. woniol

    woniol Active Member Licensed User

    You should change view size properties after adding it to AB
    Code:
    dim edtTeste as EditText
    edtTeste.Initialize(
    "")
    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))

    edtTeste.Width = 
    100dip
     
    jcesar likes this.
  3. jcesar

    jcesar Active Member Licensed User

    Thanks. I will try this...
     
  4. jcesar

    jcesar Active Member Licensed User

    Hi.

    Its possible load a scrollview into the viewpager panels ?

    When the device is in landscape mode, many of my views are out of the screen, so i need a vertical scroll to access all the views.
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can add any view you like. The sliding gesture might interfere with the vertical scrolling. You will need to test it.
     
  6. M. Giray Ozkan

    M. Giray Ozkan Member Licensed User

    Hi,

    How can I change title text color?

    Thank you
     
  7. Erel

    Erel Administrator Staff Member Licensed User

  8. Inman

    Inman Well-Known Member Licensed User

    How can I put a Switch View on this Standard Actionbar?
     
  9. Erel

    Erel Administrator Staff Member Licensed User

    I've just wrote a SwitchView class. You can use it to create a native Switch.
     
  10. Inman

    Inman Well-Known Member Licensed User

    Great. Thank you very much Erel.
     
  11. woniol

    woniol Active Member Licensed User


    Should it work for 3 or more tabs?
    When I try to add it to third tab i get this in log:
     
    Last edited: Mar 20, 2014
  12. Erel

    Erel Administrator Staff Member Licensed User

    It should work with any number of tabs:
    upload_2014-3-20_15-58-29.png

    Code:
    Sub Process_Globals

    End Sub


    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")
      bar.AddTab(
    "Blue panel")
      
    Dim h As Int = CalculateHeight(TrueFalse)
       
      vp.Initialize(
    "vp"3100%x, h)
      MapPanel.Initialize(
    "")
      
    Activity.AddView(vp.AsView, 00100%x, h)
      vp.Panels(
    1).AddView(MapPanel,00100%x, h)
      vp.Panels(
    0).Color = Colors.Red
      vp.Panels(
    2).Color = Colors.Blue
      
    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
     
  13. woniol

    woniol Active Member Licensed User

    Ok, but You still add it do the second one:
    Code:
    vp.Panels(1).AddView(MapPanel,00100%x, h)
      vp.Panels(
    0).Color = Colors.Red
      vp.Panels(
    2).Color = Colors.Blue
    please try:
    Code:
    vp.Panels(2).AddView(MapPanel,00100%x, h)
      vp.Panels(
    0).Color = Colors.Red
      vp.Panels(
    1).Color = Colors.Blue
     
    Last edited: Mar 20, 2014
  14. Erel

    Erel Administrator Staff Member Licensed User

    Actually it is in the second panel not the first (the commands order is not important).

    I see the error you get if it is in the last page. I'm not sure why it happens. Try it on any of the other panels and it will work.
     
  15. woniol

    woniol Active Member Licensed User

    Looks like it only works with
    Code:
    p.Panels(0).AddView(MapPanel,00100%x, h)
    or
    Code:
    p.Panels(1).AddView(MapPanel,00100%x, h)
    not above it
     
  16. Erel

    Erel Administrator Staff Member Licensed User

    Good catch.

    Add these two lines after you initialize ViewPager:
    Code:
    vp.Initialize("vp"10100%x, h)
      
    Dim jo As JavaObject = vp
      jo = jo.GetFieldJO(
    "vp").RunMethod("setOffscreenPageLimit"Array As Object(100)) 'the first string is "vp" (not related to the variable)
     
  17. woniol

    woniol Active Member Licensed User

    Looks like it only works with
    Code:
    p.Panels(0).AddView(MapPanel,00100%x, h)
    or
    Code:
    p.Panels(1).AddView(MapPanel,00100%x, h)
    not above it
    That's it. Thank You very much for your help.
     
  18. jcesar

    jcesar Active Member Licensed User


    Hi Erel

    The app crashes when i put the map in the last "tab" (vp.panels(2)). This code only works when the mapview is in the first or second tabs.

    Maybe i doing something wrong...
     
  19. Erel

    Erel Administrator Staff Member Licensed User

    See post #76.
     
  20. Inman

    Inman Well-Known Member Licensed User

    In most Android apps (including official Google apps like Gmail), there will be a search button on the actionbar, clicking on which will suddenly display a text box right on the actionbar itself for searching. I understand that we can do it with the above code. But if the user clicks the physical (or on screen) back button on his phone, this text box should disappear, restoring the actionbar to it's original form.

    Can we do that in B4A?
     
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