how to get RatingBar value

前端 未结 9 2374
傲寒
傲寒 2021-02-13 18:55

how to read and display rating bar value

i[0] // should be selected value

private OnClickListener onclickbutton1 = new OnClickListener() {
    public void onCli         


        
相关标签:
9条回答
  • 2021-02-13 19:43
    import android.widget.RatingBar;
    
    public class PageAboutFragment extends Fragment implements RatingBar.OnRatingBarChangeListener  {
    
    
    rbSearch.setOnRatingBarChangeListener(this);
    
    
    public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            tvRatingContent.setText(rating+"/5 Stars");
    }
    
    0 讨论(0)
  • 2021-02-13 19:47
    rbRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
                @Override
                public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
    
                    Float ratingVal = (Float) rating;
                    Float ratingvalue = (Float) rbRatingBar.getRating();
                    Toast.makeText(getApplicationContext(), " Ratings : " + String.valueOf(ratingVal) + "", Toast.LENGTH_SHORT).show();
                    Toast.makeText(getApplicationContext(), " Ratings1 : " + ratingvalue + "", Toast.LENGTH_SHORT).show();
                }
            });
    
    0 讨论(0)
  • 2021-02-13 19:47
    RatingBar rate = (RatingBar)findViewById(R.id.R_rate);
    
    //use ratings within event listner code block
    
    float rating = rate.getRating();
    
    0 讨论(0)
提交回复
热议问题