B4A Library RatingBar

This library displays a rating (or any value) with a set of images. The bar can use your own images, have any size and be placed anywhere on screen, contrary to the standard RatingBar.

rb.png


This is not a wrapper of an existing project. It's 100% my own code.
 

Attachments

  • RatingBar v1.1.zip
    33.4 KB · Views: 721
Last edited:

fredo

Well-Known Member
Licensed User
Longtime User
How to get the tag value in Changed event?
I have the RatingBar on an ULV panel.

In the ContentFiller I save the ItemID in the tag so that I can grab that value later for further actions.

28-06-_2016_13-29-38.jpg


When the user clicks on the view I usually use the "Sender"-element to get to the tag value.

28-06-_2016_09-19-25.jpg


While trying to get to the RatingBar.Tag I receive this error:

28-06-_2016_09-20-45.jpg


Am I doing something wrong?
 

Informatix

Expert
Licensed User
Longtime User
How to get the tag value in Changed event?
I have the RatingBar on an ULV panel.

In the ContentFiller I save the ItemID in the tag so that I can grab that value later for further actions.

View attachment 45545

When the user clicks on the view I usually use the "Sender"-element to get to the tag value.

View attachment 45543

While trying to get to the RatingBar.Tag I receive this error:

View attachment 45544

Am I doing something wrong?
Yes, there's a bug in the library. I'm going to fix it. Thanks for the report.
Note: I don't know what you store in the Tag property (mapItemMeal?) but it's not the itemId.
 

Informatix

Expert
Licensed User
Longtime User
How to get the tag value in Changed event?
I have the RatingBar on an ULV panel.

In the ContentFiller I save the ItemID in the tag so that I can grab that value later for further actions.

View attachment 45545

When the user clicks on the view I usually use the "Sender"-element to get to the tag value.

View attachment 45543

While trying to get to the RatingBar.Tag I receive this error:

View attachment 45544

Am I doing something wrong?
Fixed. The new version is in post #1.
 

fredo

Well-Known Member
Licensed User
Longtime User
Note: I don't know what you store in the Tag property (mapItemMeal?) but it's not the itemId.

OK, for an example it was too special since I was too lazy to create an extra demonstration app.

In the ContenFiller I use the tag properties of the views either to store the UlvItemId or some recordset-ID from the feeding SQL-query so that I can perform SQL actions to the belonging recordset.

In the above sample "mapItemMeal.Get(xIDWp2)" holds a numeric value.
 

asales

Expert
Licensed User
Longtime User
[SOLVED - see the next post]

I got this error with the example and the new version beta (6.3) of B4A

B4X:
** Activity (main) Create, isFirst = true **
main_activity_create (java line: 342)
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to flm.b4a.ratingbar.RatingBar$a
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:166)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at flm.b4a.testdialogs.main._activity_create(main.java:342)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:169)
    at flm.b4a.testdialogs.main.afterFirstLayout(main.java:102)
    at flm.b4a.testdialogs.main.access$000(main.java:17)
    at flm.b4a.testdialogs.main$WaitForLayout.run(main.java:80)
    at android.os.Handler.handleCallback(Handler.java:746)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:148)
    at android.app.ActivityThread.main(ActivityThread.java:5443)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
Caused by: java.lang.ClassCastException: java.lang.String cannot be cast to flm.b4a.ratingbar.RatingBar$a
    at flm.b4a.ratingbar.RatingBar.DesignerCreateView(SourceFile:254)
    at anywheresoftware.b4a.objects.CustomViewWrapper.AfterDesignerScript(CustomViewWrapper.java:70)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:158)
    ... 14 more
java.lang.RuntimeException: java.lang.ClassCastException: java.lang.String cannot be cast to flm.b4a.ratingbar.RatingBar$a
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
What's happened and how to fix it.

Thanks in advance for any support.
 
Last edited:

MarcoRome

Expert
Licensed User
Longtime User
Hi Fred.
I have this problem, when i tap on picture work without problem ( see point 1 ) , but if i tap "out" that picture ( see point 2 ) the picture vanish.

upload_2017-2-6_18-2-46.png


For understand better look also this movie:


Any suggestion ??
Thank you
Marco
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Fred.
I have this problem, when i tap on picture work without problem ( see point 1 ) , but if i tap "out" that picture ( see point 2 ) the picture vanish.

View attachment 52627

For understand better look also this movie:


Any suggestion ??
Thank you
Marco
Ok. Resolved ( my wrong )
if set in method Null as HalfAllowed
B4X:
RatingBar1.SetBitmaps(bmpBallOn, Null, bmpBallOff)

but dont set this property in Design as HalfAllowed = False, of course i have this unwanted effect.
Thank you Fred for this library.
 
Top