B4A Library BottomNavigation

This is a wrap for this Github project.

BottomNavigation
Author:
DonManfred (wrapper)
Version: 1
  • BottomNavigation
    Events:
    • onNavigationItemClick (index As Int)
    Fields:
    • ba As BA
    Methods:
    • BringToFront
    • DesignerCreateView (base As PanelWrapper, lw As LabelWrapper, props As Map)
    • GetApplicationDrawableID (DrawableName As String) As Int
      Get a Drawable from the Application Resources.
      Returns Null if the Drawable is not found.
    • Initialize (EventName As String)
    • Invalidate
    • Invalidate2 (arg0 As Rect)
    • Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • IsInitialized As Boolean
    • RemoveView
    • RequestFocus As Boolean
    • SendToBack
    • SetBackgroundImage (arg0 As Bitmap)
    • SetColorAnimated (arg0 As Int, arg1 As Int, arg2 As Int)
    • SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
    • SetLayoutAnimated (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int, arg4 As Int)
    • SetVisibleAnimated (arg0 As Int, arg1 As Boolean)
    • addTab (item As BottomNavigationItem)
    • isColoredBackground (coloredBackground As Boolean)
    • isWithText (withText As Boolean)
    Properties:
    • Background As Drawable
    • Color As Int [write only]
    • Enabled As Boolean
    • Height As Int
    • ItemActiveColorWithoutColoredBackground As Int [write only]
    • Left As Int
    • Parent As Object [read only]
    • Tag As Object
    • Top As Int
    • Visible As Boolean
    • Width As Int
  • BottomNavigationItem
    Methods:
    • Initialize (title As String, color As Int, imageResource As String)
    • IsInitialized As Boolean
    • setImageResource (imageResource As String)
    Properties:
    • Color As Int
    • ImageResource As Int [read only]
    • Title As String
  • BottomNavigationUtils
    Methods:
    • Initialize
    • IsInitialized As Boolean
    • backgroundColorChange (view As View, fromColor As Int, toColor As Int)
    • changeTextColor (textView As TextView, fromColor As Int, toColor As Int)
    • changeTextSize (textView As TextView, from As Float, to As Float)
    • changeTopPadding (view As View, fromPadding As Int, toPadding As Int)
    • imageColorChange (image As ImageView, fromColor As Int, toColor As Int)

gifView2.gif
 

Attachments

  • BottomNavigationEx.zip
    11.2 KB · Views: 1,389
  • BottomNavigationV1.0.0.zip
    18.6 KB · Views: 1,026
  • BottomNavigationExViewPager.zip
    11.4 KB · Views: 1,155
  • BottomNavigationV1.1.zip
    24.2 KB · Views: 1,234
Last edited:

tuhatinhvn

Active Member
Licensed User
Longtime User
how to set height and change icon??

your library are always very little information and very hard to use!
 

DonManfred

Expert
Licensed User
Longtime User

Mashiane

Expert
Licensed User
Longtime User
I have played around with this, here is another example.

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")
    ' this is the color of a selected item when isColoredBackground(False)
    Navigation.ItemActiveColorWithoutColoredBackground = Colors.Magenta
    ' background color of navigation bar
    Navigation.Color = Colors.green
    ' when an item is clicked, does the color change? True = Yes
    Navigation.isColoredBackground(True)
   
    AddNavigationItem("10K", Colors.Blue, "likeb")
    AddNavigationItem("2K", Colors.Red, "comment")
    AddNavigationItem("Following", Colors.Yellow, "following")
End Sub

' define a single method to add an item
Sub AddNavigationItem(sTitle As String, clr As Int, res As String)
    ' the color here works when the isColoredBackground(true)
    ' when clicked, the color of the whole BottomNavigation turns into that
    Dim Item As BottomNavigationItem
    Item.Initialize(sTitle,clr,res)
    Navigation.addTab(Item)
End Sub
 

Attachments

  • BottomNavigationExample.zip
    16.8 KB · Views: 381

billyrudi

Active Member
Licensed User
Longtime User
Hi, there is a way to rise every bottom click the onNavigationItemClick event? even though i already clicked it?

regards Paolo
 

fredo

Well-Known Member
Licensed User
Longtime User

It seems the author updated the lib and there are some new important features.
  • disableShadow
  • setItemActiveColorWithoutColoredBackground
  • setTextActiveSize
  • setTextInactiveSize
  • setFont
  • willNotRecreate
  • setUpWithViewPager
  • selectTab
  • disableViewPagerSlide

@DonManfred would it be possible that you update the wrap?

(I tried to make a wrap with SLC by myself but I always get the error:
BottomNavigationView.java:10: error: package android.support.v4.content does not exist
import android.support.v4.content.ContextCompat;
and I don't know how to fix it.)
 
Last edited:

DonManfred

Expert
Licensed User
Longtime User
would it be possible that you update the wrap?
See Post #1

I´ve updated the lib to V1.1 using the newest github source...
I added a second sample to show the use of the ahviewpager... It is not using the color and imageresource arrays btw...
 

BarryW

Active Member
Licensed User
Longtime User
i get an error

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 336)
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
at b4a.example.BottomNavigation.main._activity_create(main.java:336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
at b4a.example.BottomNavigation.main.afterFirstLayout(main.java:102)
at b4a.example.BottomNavigation.main.access$000(main.java:17)
at b4a.example.BottomNavigation.main$WaitForLayout.run(main.java:80)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:149)
at android.app.ActivityThread.main(ActivityThread.java:5257)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:64)
at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
... 17 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1166)
at android.content.res.Resources.getDimension(Resources.java:552)
at com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationView.<init>(BottomNavigationView.java:35)
at com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationView.<init>(BottomNavigationView.java:87)
at com.luseen.luseenbottomnavigation.BottomNavigation.BottomNavigationView.<init>(BottomNavigationView.java:83)
at de.donmanfred.BottomNavigationViewWrapper._initialize(BottomNavigationViewWrapper.java:72)
... 21 more
 

MarcoRome

Expert
Licensed User
Longtime User
I


i alreader add those things
This happen with library 1.1 ( Don also me have this error with Rel.1.1 )
If you try with library 1.0 work and try both example ( ButtonNavigationEx or ButtonNabvigationExViewPage ) will work without problem
 

MarcoRome

Expert
Licensed User
Longtime User
This happen with library 1.1 ( Don also me have this error with Rel.1.1 )
If you try with library 1.0 work and try both example ( ButtonNavigationEx or ButtonNabvigationExViewPage ) will work without problem

Maybe Don have forget "new" folder Resource for Rel.1.1 ( in 2 example ButtonNabvigationExViewPage dont exist this folder and in first example ButtonNavigationEx is relative library 1.0 )
 

JNG

Member
Licensed User
Will it be possible to use IconFonts in the navigation bar e.g.
FontAwesome / Material Icons ? if yes pl. help how.?

regards
jng
 
Top