B4A Class [B4X] [XUI] Badger - Add badges to views

This class is compatible with B4A, B4i and B4J.

Badger.gif


Badger_B4J.gif



SS-2017-07-18_09.31.00.png


Simple class that adds "badges" to views.

Usage example:
B4X:
'increase badge by one.
badger1.SetBadge(Label1, badger1.GetBadge(Label1) + 1)

You can change the colors and radius in the class code.
The class is included in all three attached examples.


Versions

V3.10 - Fixes issue in B4A with targetSdkVersion = 28
V3.00 - Based on XUI. Requires XUI v1.20

Latest version is included in the B4A project.
 

Attachments

  • Badger_B4i.zip
    4.5 KB · Views: 812
  • Badger_B4J.zip
    3 KB · Views: 895
  • Badger_B4A.zip
    9 KB · Views: 1,173
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
V3.00 is released. It is based on XUI library. With the exception of the panel's creation code:
B4X:
#if B4J
   Dim p As Pane
#else
   Dim p As Panel
#end if
   p.Initialize("")
#if B4A
   p.SetElevationAnimated(animationDuration, 8dip)
#end if

the class code is exactly the same in all three platforms.

This is a nice example of the power of XUI library.
 

Gubi

Member
Licensed User
How can I add a badge to a tabstrip in b4i ?

I tried:

B4X:
Sub TabStripSetBadge
    Dim i As Int = 0
    
    TabStripBadger.Initialize
    
    For i = 0 To TabPages.Size - 1
        Dim p As Page = TabPages.Get(i)
        Dim lbl As B4XView = p.TitleView

        If i = 1 Then
            TabStripBadger.SetBadge(lbl, iBadge1)
        End If
        If i = 2 And Then
            TabStripBadger.SetBadge(lbl, iBadge2)
        End If
    Next
End Sub

but the class Badger crashes at Sub createNewPanel: the view.Parent was not initialized
 

imbault

Well-Known Member
Licensed User
Longtime User
Hi,

Very good functionality, as always from @Erel, is it possible to catch a click on the badge?

Thanks a lot

Patrick
 
Top