B4A Library BadgeView - Add Badges to your views

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Jan 27, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    ViewBadger
    Version:
    0.25

    This is a wrapper for this java-library

    [​IMG]




    ViewBadger
    Version:
    0.25
    • Badger
      Events:
      • onClick (value As Object)
      Methods:
      • Hide
      • Initialize (event As String, v As View, text As String, backgrouncColor As Int, AddClickListener As Boolean)
      • Show
      • Toggle
      • setPadding (left As Int, top As Int, right As Int, bottom As Int)
      Properties:
      • Position As Int [write only]
      • Tag As Object [write only]
      • Text As String [write only]

    The Library is Donationware. You can try it out for free. If you then want to include the library in your project then you are forced to donate for this library. You can donate as much you want :)
    [​IMG]

    The functionality of the "ClickListener" is successfully tested on the following Views:
    Button, Panel, Label, ImageView, ToggleButton, RadioButton, ProgressBar and CheckBox

    A ClickListener should NOT be set on the following Views (set last parameter of Initialize to FALSE here)
    - Listviews
    - Spinner
    (maybe more but i have not tested them)
     

    Attached Files:

    Last edited: Jan 30, 2015
    GMan, Mashiane, koaunglay and 13 others like this.
  2. Peter Simpson

    Peter Simpson Expert Licensed User

    Nice, it works well...
     
  3. johndb

    johndb Active Member Licensed User

    Is it possible to change the color of the text?
     
  4. DonManfred

    DonManfred Expert Licensed User

    In the next release you can
    - Set the Textcolor
    Code:
    badgeLbl.TextColor = Colors.Red
    - Set the Textsize
    Code:
    badgeLbl.TextSize = 24
    - Set the fontface
    Code:
    Dim MyFont As Typeface
    MyFont = 
    Typeface.LoadFromAssets("digi.ttf")
    badgeLbl.Typeface = MyFont
    See this example
    [​IMG]
     
    Peter Simpson and johndb like this.
  5. Troberg

    Troberg Well-Known Member Licensed User

    Badges? Badges! We don't need no stinking badges!

    Sorry, but someone had to say it. :)

    Looks very nice!

    Some possible enhancements:

    * Option to put them outside the "badged" view. Good for putting help tips.
    * In combination with the above, option for "speech bubble pointer".

    That way, you could have a speech bubble over, say, a button, saying "Click this to add songs". Somewhat like I did in the penultimate screenshot here (but I didn't do the speach bubble pointer): https://play.google.com/store/apps/details?id=com.troberg.jukedroid
     
  6. DonManfred

    DonManfred Expert Licensed User

    It looks good on views which has an margin > 0. Buttons for example. Or ListView...

    [​IMG]


    If there is no margin than the badge go outside of the visible area of this view....

    [​IMG]

    But for buttons you can set the margin in the next version
    Code:
    badgeBTN3.Margin = 0
    or
    Code:
    badgeBTN3.setMargin2(horizontal,vertical)
     
    johndb and Peter Simpson like this.
  7. DonManfred

    DonManfred Expert Licensed User

    Version 0.25 online (i´ve updated the files in the first post)
     
    johndb likes this.
  8. Troberg

    Troberg Well-Known Member Licensed User

    Ah, I see, the badges live in the parent object, they are not simply attached to it. Then I understand whey they need to stay within it.

    Anyway, still nice!
     
  9. johndb

    johndb Active Member Licensed User

    I received the following error when setting "AddClickListener" to True in the Initialization using a Spinner as a view.
    When "AddClickListener" is set to false then there is no error.

    java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
    at android.widget.AdapterView.setOnClickListener(AdapterView.java:841)
    at de.donmanfred.Badger.Initialize(Badger.java:44)
    at com.sctech.ebase.main._activity_create(main.java:612)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:175)
    at com.sctech.ebase.main.afterFirstLayout(main.java:98)
    at com.sctech.ebase.main.access$100(main.java:16)
    at com.sctech.ebase.main$WaitForLayout.run(main.java:76)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5579)
    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:1268)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1084)
    at dalvik.system.NativeStart.main(Native Method)
    java.lang.RuntimeException: Don't call setOnClickListener for an AdapterView. You probably want setOnItemClickListener instead
     
  10. DonManfred

    DonManfred Expert Licensed User

    Seems not to work with a Spinner.
    maybe we can set a listener on a spinneritem
     
    johndb likes this.
  11. johndb

    johndb Active Member Licensed User

    I'm not using the AddClickListener event setting in my application so it's not a problem. Great library! I've sent you a little token of appreciation ;)

    John
     
    DonManfred likes this.
  12. DonManfred

    DonManfred Expert Licensed User

    If you set the last parameter of the initialize-command to true then the lib will try to add a clicklistener. Set the last parameter to false in this case. No listener will be created then.
    i´ll try to change the lib so that we maybe can use a onitemclicklistener on spinners...
     
    Peter Simpson and johndb like this.
  13. BarryW

    BarryW Active Member Licensed User

    When i set the addclicklistener to true the view with this badge also trigger the badge click event. how to do only the badge will trigger the event not the view handling this badge... Tnx
     
  14. DonManfred

    DonManfred Expert Licensed User

    It cannot be handled alone.

    The new object is an extension which is painted on the view itself. Setting the clicklistener allows you to get the click-event called when the badge is tapped.
     
    Peter Simpson likes this.
  15. DonManfred

    DonManfred Expert Licensed User

    Just thinking loud: Maybe i just need to raise another event instead of the onclick... Maybe onBadgeClick...
    Will try this later...
     
  16. DonManfred

    DonManfred Expert Licensed User

    No. Did not work :(:mad:
    The normal Click event is raised always too. so i guess putting a badge on a Radiobutton, checkbox (and all other which already have a clickevent) is not a good idea. On views like a progressbar it works fine
     
  17. Reids

    Reids Member Licensed User

    How to add badge on a tabhost or a listview item
    I have FriendList.AddTwoLinesAndBitmap, I can put on Friendlist listview, but I cannot place badge on List Item itself because list item not a view :(
     
  18. Peter Simpson

    Peter Simpson Expert Licensed User

    That's not possible, as you said yourself the items are not Views @Reids...
     
    Reids likes this.
  19. awakenblueheart

    awakenblueheart Member Licensed User

    I am using this badge. When the listbox item is selected, the badge should be change. But the badge become overlay on each other each time listbox item changed. How to solve this ya?
    Tq.
     
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