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

Erel

Administrator
Staff member
Licensed User
This class is compatible with B4A, B4i and B4J.








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.00 - Based on XUI. Requires XUI v1.20
 

Attachments

Last edited:

Erel

Administrator
Staff member
Licensed 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
 

Erel

Administrator
Staff member
Licensed User
It will not work with iTabStrip headers as they are handled in a non-standard way by the library.
 
Top