B4A Library ViewTagger v1.0.1

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


B4X:
    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)
 

Attachments

Last edited:

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
 

itgirl

Active Member
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:

View attachment 32231

Any idea ?
Thanks
Marco
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 ]
 

MarcoRome

Expert
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 ]
Yes you can see in picture... NJDude is right. Anyway thank you itgirl
 

itgirl

Active Member
Licensed User
Yes you can see in picture... NJDude is right. Anyway thank you itgirl
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 ;)
 

DonManfred

Expert
Licensed User
Hi Manfred isn't so..sorry.
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
 

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 ;)
 

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.


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.05
 

DonManfred

Expert
Licensed User
I am using some libraries, like Appcompat
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:

jotaele

Member
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?
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.
 

Attachments

DonManfred

Expert
Licensed User
I upload the test.zip
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

B4X:
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
B4X:
    SetElevation(Button1,0)
    SetElevation(ToggleButton1,0)
 

so27

Active Member
Licensed User
Hi DonManfred,

I use the Lib and have the following problem:

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

B4X:
** 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)
 
Top