android - How to set value in RatingBar? -


hello want set value in ratingbar in android don't nothing.

this code.

ratingbar ratingbar = (ratingbar) findviewbyid(r.id.ratingbar); if(gameviewmoon.valorbadg == 4) {       toast.maketext(getapplicationcontext(), r.string.levelfive, toast.length_short).show();       ratingbar.setrating(4);       gameviewmoon.valorbadg = 0; } 

xml

 <ratingbar         android:id="@+id/ratingbar"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:numstars="5"         android:stepsize="1.0"         android:rating="2.0"         android:layout_below="@+id/tv_current_score_value"         android:layout_centerhorizontal="true" /> 

i recomend start using new appcompatratingbar have support new , old devices. here documentation in case need it: https://developer.android.com/reference/android/support/v7/widget/appcompatratingbar.html


Comments