Search in sources :

Example 11 with RatingBar

use of android.widget.RatingBar in project BaseRecyclerViewAdapterHelper by CymChad.

the class BaseViewHolder method setRating.

/**
     * Sets the rating (the number of stars filled) and max of a RatingBar.
     *
     * @param viewId The view id.
     * @param rating The rating.
     * @param max    The range of the RatingBar to 0...max.
     * @return The BaseViewHolder for chaining.
     */
public BaseViewHolder setRating(int viewId, float rating, int max) {
    RatingBar view = getView(viewId);
    view.setMax(max);
    view.setRating(rating);
    return this;
}
Also used : RatingBar(android.widget.RatingBar)

Example 12 with RatingBar

use of android.widget.RatingBar in project coursera-android by aporter.

the class RatingsBarActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    final TextView tv = (TextView) findViewById(R.id.textView);
    final RatingBar bar = (RatingBar) findViewById(R.id.ratingbar);
    bar.setOnRatingBarChangeListener(new OnRatingBarChangeListener() {

        // Called when the user swipes the RatingBar
        @Override
        public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
            tv.setText("Rating:" + rating);
        }
    });
}
Also used : OnRatingBarChangeListener(android.widget.RatingBar.OnRatingBarChangeListener) TextView(android.widget.TextView) RatingBar(android.widget.RatingBar)

Example 13 with RatingBar

use of android.widget.RatingBar in project cw-advandroid by commonsguy.

the class RateableWrapper method getView.

public View getView(int position, View convertView, ViewGroup parent) {
    ViewWrapper wrap = null;
    View row = convertView;
    if (convertView == null) {
        LinearLayout layout = new LinearLayout(ctxt);
        RatingBar rate = new RatingBar(ctxt);
        rate.setNumStars(3);
        rate.setStepSize(1.0f);
        View guts = delegate.getView(position, null, parent);
        layout.setOrientation(LinearLayout.HORIZONTAL);
        rate.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT));
        guts.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.FILL_PARENT));
        RatingBar.OnRatingBarChangeListener l = new RatingBar.OnRatingBarChangeListener() {

            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromTouch) {
                rates[(Integer) ratingBar.getTag()] = rating;
            }
        };
        rate.setOnRatingBarChangeListener(l);
        layout.addView(rate);
        layout.addView(guts);
        wrap = new ViewWrapper(layout);
        wrap.setGuts(guts);
        layout.setTag(wrap);
        rate.setTag(new Integer(position));
        rate.setRating(rates[position]);
        row = layout;
    } else {
        wrap = (ViewWrapper) convertView.getTag();
        wrap.setGuts(delegate.getView(position, wrap.getGuts(), parent));
        wrap.getRatingBar().setTag(new Integer(position));
        wrap.getRatingBar().setRating(rates[position]);
    }
    return (row);
}
Also used : View(android.view.View) RatingBar(android.widget.RatingBar) LinearLayout(android.widget.LinearLayout)

Example 14 with RatingBar

use of android.widget.RatingBar in project cardslib by gabrielemariotti.

the class GplayCard method setupInnerViewElements.

@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
    TextView title = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_title);
    title.setText("FREE");
    TextView subtitle = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_subtitle);
    subtitle.setText("Very popular with...");
    RatingBar mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_gplay_main_inner_ratingBar);
    mRatingBar.setNumStars(5);
    mRatingBar.setMax(5);
    mRatingBar.setStepSize(0.5f);
    mRatingBar.setRating(4.7f);
}
Also used : TextView(android.widget.TextView) RatingBar(android.widget.RatingBar)

Example 15 with RatingBar

use of android.widget.RatingBar in project cardslib by gabrielemariotti.

the class GplayCardCustomSource method setupInnerViewElements.

@Override
public void setupInnerViewElements(ViewGroup parent, View view) {
    TextView title = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_title);
    title.setText("FREE");
    TextView subtitle = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_subtitle);
    subtitle.setText("Very popular with...");
    RatingBar mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_gplay_main_inner_ratingBar);
    mRatingBar.setNumStars(5);
    mRatingBar.setMax(5);
    mRatingBar.setStepSize(0.5f);
    mRatingBar.setRating(4.7f);
}
Also used : TextView(android.widget.TextView) RatingBar(android.widget.RatingBar)

Aggregations

RatingBar (android.widget.RatingBar)24 TextView (android.widget.TextView)10 View (android.view.View)8 ImageView (android.widget.ImageView)3 OnRatingBarChangeListener (android.widget.RatingBar.OnRatingBarChangeListener)3 AlertDialog (android.app.AlertDialog)2 Intent (android.content.Intent)2 CompoundButton (android.widget.CompoundButton)2 Before (org.junit.Before)2 ContentValues (android.content.ContentValues)1 Paint (android.graphics.Paint)1 MediaMetadataRetriever (android.media.MediaMetadataRetriever)1 NonNull (android.support.annotation.NonNull)1 KeyEvent (android.view.KeyEvent)1 LayoutInflater (android.view.LayoutInflater)1 OnClickListener (android.view.View.OnClickListener)1 OnKeyListener (android.view.View.OnKeyListener)1 OnLongClickListener (android.view.View.OnLongClickListener)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1