B4A Library ViewTagger v1.0.1

Discussion in 'Additional libraries, classes and official updates' started by DonManfred, Feb 15, 2015.

  1. DonManfred

    DonManfred Expert Licensed User

    This library allows you to put labels on the top left or top right edge of an view.

    It is a wrapper for this Github-Project.

    ViewTagger
    Version:
    1.04
    • ViewTagger
      Events:
      • onClick (value As Object)
      Methods:
      • AddToView (text As String, backgroundColor As Int, textColor As Int, targetView As View, distance As Int, positionLeft As Boolean)
        AddToView will add a Banner to this view.
        This methods creates a NEW Banner setup with
        the given parameters here.

        This is the default Method you should use.
        If you want to be more precise in the definition of
        the banner you should look at the other methods

        text: The Text to use on the Banner
        backgroundColor sets the color for the background.
        textColor sets the TextColor
        tagetView: The view the Banner should applied to
        distance: The distance from the upper left/right corner for the Banner
        positionLeft: Can be true or false. When set to true the banner will
        be placed in the upper LEFT corner. When set to false the Banner is
        placed in the upper RIGHT corner. Only this two positions are available!
      • AddToView2 (targetView As View, distance As Int, positionLeft As Boolean)
        AddToView2 will add the customized Banner to a view.
        Parameters:
        tagetView: The view the Banner should applied to
        distance: The distance from the upper left/right corner for the Banner
        positionLeft: Can be true or false. When set to true the banner will
        be placed in the upper LEFT corner. When set to false the Banner is
        placed in the upper RIGHT corner. Only this two positions are available!
      • Initialize (EventName As String, pkg As String)
        Initialize the ViewTagger
      • NewBanner
        Creates a new Banner reference
        You can use any method except AddToView (which will always generate a
        new Banner setup with the given parameters) to customize the banner
        before you add it to a view with AddtoView2
      • setPadding (left As Int, top As Int, right As Int, bottom As Int)
        Set the Banners padding
      Properties:
      • BackgroundColor As Int [write only]
        Set the background color for the banner
      • Tag As Object [write only]
        Set the tag for this Banner. The tag is used in onClick Event
        to inform you
      • Text As String [write only]
        Set the text for the banner
      • TextColor As Int [write only]
        Set the text color for the banner
      • TextSize As Float [write only]
        Set the Textsize to use for this banner
      • Typeface As Typeface [write only]
        Set the Typeface to use for this banner


    Code:
    Spinner1.Add("Spinner...")
        vt.Initialize(
    "lv")
        
    ' Button
        vt.AddToView("Left",Colors.Red, Colors.White,Button1,20,True)
        vt.AddToView(
    "Right",Colors.White, Colors.Black,Button1,20,False)

        
    ' Imageview
        vt.AddToView("Featuring",Colors.Blue, Colors.White,ImageView1,20,False)

        
    ' Label
        vt.AddToView("HOT",Colors.Red, Colors.White,Label1,5,True)

        
    ' Toggle
        vt.AddToView("HOT",Colors.Red, Colors.White,ToggleButton1,20,False)

        
    ' Spinner
        vt.AddToView("NEW",Colors.Red, Colors.White,Spinner1,20,False)

        
    ' EditText
        vt.AddToView("42",Colors.Red, Colors.White,EditText1,20,False)

        
    ' ListView
        ListView1.AddSingleLine("Item 1")
        ListView1.AddSingleLine(
    "Item 2")
        vt.AddToView(
    "100",Colors.Red, Colors.White,ListView1,20,False)

        
    ' ProgressBar
        ProgressBar1.Indeterminate = False
        ProgressBar1.Progress = 
    50
        vt.AddToView(
    "Yo!",Colors.Red, Colors.White,ProgressBar1,20,False)
    [​IMG]
     

    Attached Files:

    Last edited: Feb 16, 2015
  2. itgirl

    itgirl Active Member Licensed User

    wow this is amazing i was doing so manually , maaany thanks for this amazing one
     
    Tom Christman and DonManfred like this.
  3. MarcoRome

    MarcoRome Expert Licensed User

    Hi Manfred thnak you for this fantastic library but i have problem.
    After that i open your example and copy your library i have this result:

    Screenshot 2015-02-15 19.33.35.png

    Any idea ?
    Thanks
    Marco
     
  4. itgirl

    itgirl Active Member Licensed User

    did you mark the lib in the libraries tab ?
    infact if you open the example before you copy the lib it wont be marked, you can just refresh the lib list and mark the lib [ LabelView ]
     
  5. NJDude

    NJDude Expert Licensed User

    The library name has been changed, but the author forgot to update the new name into the lib. ;)
     
    MarcoRome and RauchG like this.
  6. MarcoRome

    MarcoRome Expert Licensed User

    Yes you can see in picture... NJDude is right. Anyway thank you itgirl
     
  7. itgirl

    itgirl Active Member Licensed User

    yeah because the lib is called LabelView in my libs and i didn't see it in your picture so i thought you didn't activate it , but as NJDude said the lib name changed ;)
     
  8. DonManfred

    DonManfred Expert Licensed User

    the lib has hanged in libs tab too. newname is ViewTagger.
    Note that you now have the same lib under two names in additional libs.

    unmark the old one, mark the new one and redim the mainobject. Delete LabelView.* then from additional libs
     
  9. MarcoRome

    MarcoRome Expert Licensed User

    Hi Manfred isn't so..sorry.
    I download your example / library yesterday ( more or less 7.15 PM ) and if you see in ViewTaggerEx.zip i have only example ( that you see in my picture ) and library ViewTaggerLibraryfilesv1.0.1.zip which contains only "new" library ViewTagger.jar + xml. I havent LabelView.* in my lib.
    Thank you
    Marco
     
  10. DonManfred

    DonManfred Expert Licensed User

    I´ve uploaded a new example for the newest version. I also uploaded a new libraryversion.

    Changes:
    In addition to the one-command-variant AddToView you now can customize more and then use AddToView2
    You can set Textcolor, Backgroundcolor, Typeface, fontsize and Padding
    The new example shows the use of a custom ttf font
     
    MarcoRome likes this.
  11. MarcoRome

    MarcoRome Expert Licensed User

    Now all work...Great addon
    Thank Manfred
    Marco
     
    DonManfred likes this.
  12. Troberg

    Troberg Well-Known Member Licensed User

    Wow, this is cool! My mind reels with new ideas of what I could do with this.
     
    DonManfred likes this.
  13. DonManfred

    DonManfred Expert Licensed User

    You can leave a likes (or two) in return :)
     
    Troberg and thedesolatesoul like this.
  14. migrec

    migrec Member Licensed User

    Thank you for this awesome and easy-to-use library! Will be used a lot in my apps, maybe on every single view ;)
     
  15. Peter Simpson

    Peter Simpson Expert Licensed User

    DonManfred likes this.
  16. jotaele

    jotaele Member Licensed User

    Hi all, @DonManfred

    I tested in a Lollipop device (but I mean that may be it's no problem related to Lollipop devices), but the label is showing BEHIND the view. You can only see the corners. The label is behind the button, for example.

    Well. In this project I am using some libraries, like Appcompat, FontAwesome, MSMaterialDrawer, MSDynamicGridView, CardView ... Maybe a conflict between them?

    Your example is working fine in this device, like in others with Kit Kat 4.4.

    I will test our example with AppCompat later. It's the only thing that change appareance of the buttons.


     
  17. DonManfred

    DonManfred Expert Licensed User

    That could maybe the problem be. Maybe you need to set the .. [thinking: damned what was the name of it...] Elevation. I mean; maybe i need to change something in the lib...

    But for today i don´t have the time to setup a small example project using AppCompat...

    Can you try to reproduce this in a small app (one activity) and upload it here?
     
    Last edited: Oct 19, 2015
  18. jotaele

    jotaele Member Licensed User

    I did it, and has an error in buttons. Other views works well.

    I am compiling with Appcompat Library Version 2. B4A Version 5.20. Java Version 1.8 Android version 23.

    I upload the test.zip with Export option from menu. If you want I can send you with libraries, but I don't know if I can upload a project with libraries without permision.

    Thanks.
     

    Attached Files:

  19. DonManfred

    DonManfred Expert Licensed User

    Thank you. I see the probem now.

    Add this sub (if you are compiling against 21+ SDK then you can remove the phone reference and the check

    Code:
    Sub SetElevation(v As View, e As Float)
        
    Dim jo As JavaObject
        
    Dim p As Phone

        
    If p.SdkVersion >= 21 Then
            jo = v
            jo.RunMethod(
    "setElevation"Array As Object(e))
        
    End If
    End Sub
    and add this to activity_create
    Code:
    SetElevation(Button1,0)
        SetElevation(ToggleButton1,
    0)
     
  20. so27

    so27 Active Member Licensed User

    Hi DonManfred,

    I use the Lib and have the following problem:

    Code:
    VT.Initialize("lv"Application.PackageName)
    VT.AddToView(
    "NEW",Colors.Red, Colors.White,Button3,20,False)
    Bevor in Globals:
    Code:
    Dim vt As ViewTagger

    Code:
    ** Service (starter) Create **
    ** 
    Service (starter) Start **
    ** 
    Activity (main) Create, isFirst = true **
    main_activity_create (java line: 
    363)
    java.lang.ClassCastException: android.widget.FrameLayout$LayoutParams cannot be cast 
    to anywheresoftware.b4a.BALayout$LayoutParams
        at anywheresoftware.b4a.objects.ViewWrapper.setLeft(ViewWrapper.java:
    170)
        at de.owsianowski.verliebt.main._activity_create(main.java:
    363)
        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 de.owsianowski.verliebt.main.afterFirstLayout(main.java:
    102)
        at de.owsianowski.verliebt.main.access$
    000(main.java:17)
        at de.owsianowski.verliebt.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:
    136)
        at android.app.ActivityThread.main(ActivityThread.java:
    5139)
        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:
    796)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:
    612)
        at dalvik.system.NativeStart.main(Native Method)
     
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