Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Updated the SimpleFragment.java #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Updated the SimpleFragment.java
I refactored the code of showing Ratings to the mobile screen . This code is just one line code and does not need to create another variable to do the task.
  • Loading branch information
M-Ali-B authored Jun 12, 2019
commit 05637473dbb9a1dbea2995949ab28ab50f4bbb92
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,17 @@ public void onCheckedChanged(RadioGroup group,
@Override
public void onRatingChanged(RatingBar ratingBar,
float rating, boolean fromUser) {
// Get rating and show Toast with rating.
String myRating = (getString(R.string.my_rating) +
String.valueOf(ratingBar.getRating()));
Toast.makeText(getContext(), myRating,
Toast.LENGTH_SHORT).show();
// Get rating and show Toast with rating(Old).
// String myRating = (getString(R.string.my_rating) +
// String.valueOf(ratingBar.getRating()));
// Toast.makeText(getContext(), myRating,
// Toast.LENGTH_SHORT).show();

// Get rating and show Toast with rating(New).
// instead of above code you can write only the following as the 'rating' parameter is there to complete your needs
Toast.makeText(getContext(), rating,
// Toast.LENGTH_SHORT).show();

}
});

Expand Down