Android Question ASRatingBar - View cannot be converted to ASRatingBar

Antonio Ferreira

Member
Licensed User
Longtime User
I use ASRatingbar in a CustomListView, and the CustomListView display correctely the ASRatingbar.CurrentRating.
When I want to change the ASRatingbar.CurrentRating in the CustomListView I have the compiling error "View cannot be converted to ASRatingBar"

B4X:
Dim pnl As Panel
pnl= xclv.GetPanel(Mindex)
Dim AS_Rating1 As ASRatingBar
AS_Rating1=pnl.GetView(11)
AS_Rating1.CurrentRating=5

Compiling Error on "Dim AS_Rating1 As ASRatingBar"
src\glose\pedidos\pedidos_em_avaliacao.java:755: error: incompatible types: View cannot be converted To asratingbar
_as_rating1 = (glose.pedidos.asratingbar)(_pnl.GetView((int) (11)).getObject());


Thank you in advance.
 

Alexander Stolte

Expert
Licensed User
Longtime User
@angel_ is correct, here is a article about it:
 
Upvote 0

Antonio Ferreira

Member
Licensed User
Longtime User
Try

B4X:
AS_Rating1=pnl.GetView(11).tag
Thank you Angel

I don't have the compiling error but a runtime error "java.lang.ClassCastException: java.lang.String cannot be cast to glose.pedidos.asratingbar" on AS_Rating1=pnl.GetView(11).tag


B4X:
Dim pnl As Panel
pnl= xclv.GetPanel(Mindex)
Dim AS_Rating1 As ASRatingBar
AS_Rating1=pnl.GetView(11).tag
AS_Rating1.CurrentRating=5
 
Upvote 0
Top