Reputation: 696
I'm using a RatingBar and OnRatingBarChangeListener in my Code.
The user can the rating once and after this I set
ratingBar.setEnabled(false)
.
I want to show the user advice that he can't rate anymore.
How can I achieve to set a Toast after the user touches the disabled RatingBar?
Anybody an idea?
greetings
Upvotes: 42
Views: 36246
Reputation: 571
Set
ratingbar.setIsIndicator(true)
Now set the onClick Listener of rating bar or any parent view and display a toast if you receive a click
Upvotes: 2
Reputation: 761
After applying either style="?android:attr/ratingBarStyleSmall" or scaleX/scaleY the click interaction with RatingBar is disabled. This works for me. Hope this helps you!
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:transformPivotX="0dp"
android:transformPivotY="0dp"
android:scaleX="0.8"
android:scaleY="0.8"
android:isIndicator="false"
android:numStars="5"
android:stepSize="0.5"/>
Just to add up, android:isIndicator="false" made the differece.
Upvotes: 0
Reputation: 1390
You could set the rating to isIndicator after the user makes his first change You should prompt the user to make sure his change is exactly as he wished. It can get pretty difficult to rate when the property stepSize (how precise the rating is) is 0.5
//You could prompt the user using a dialog to confirm he is done rating
ratingBar.setIsIndicator(true);
That should leave the UI unchanged(no greyish blur) and prevent the user from making a change (just like setEnabled(false))
In XML Layout
android:isIndicator="true"
Hope it helped
Upvotes: 92
Reputation: 13436
As @Br0therzS0ul noted, it's isIndicator
.
Here's how in XMl:
android:isIndicator="true"
Upvotes: 36
Reputation: 12685
its very simple write in your onClick() method
if(ratingBar.getEnabled()){
Toast.makeText(<>,<YOUR message>,<>);
{
Upvotes: 0
Reputation: 610
The moment you disable the rating bar, you could make an invisble overlay that will display a toast when it's clicked.
Upvotes: 3