android.widget.RatingBar Java Examples

The following examples show how to use android.widget.RatingBar. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ViewUtil.java    From sa-sdk-android with Apache License 2.0 6 votes vote down vote up
static boolean isTrackEvent(View view, boolean isFromUser) {
    if (view instanceof CheckBox) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof RadioButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof ToggleButton) {
        if (!isFromUser) {
            return false;
        }
    } else if (view instanceof CompoundButton) {
        if (!isFromUser) {
            return false;
        }
    }
    if (view instanceof RatingBar) {
        if (!isFromUser) {
            return false;
        }
    }
    return true;
}
 
Example #2
Source File: Activity_QRcodeResult.java    From FoodOrdering with Apache License 2.0 6 votes vote down vote up
private void initView() {
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    foods_imageView = (ImageView) findViewById(R.id.foods_image_view);
    foods_ingredients_text = (TextView) findViewById(R.id.foods_ingredients_text);
    foods_description_text = (TextView) findViewById(R.id.foods_description_text);
    fab_comment = (FloatingActionButton) findViewById(R.id.fab_comment);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    collapsingToolbar.setTitle(name);

    Glide.with(this).load(imageUrl).into(foods_imageView);
    foods_ingredients_text.setText("配料:" + ingredients);
    foods_description_text.setText("简介:" + description);
    ratingBar.setProgress(rating);
}
 
Example #3
Source File: RatingsBarActivity.java    From coursera-android with MIT License 6 votes vote down vote up
@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);
	}
});
  }
 
Example #4
Source File: RatingBar1.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.ratingbar_1);
    
    mRatingText = (TextView) findViewById(R.id.rating);

    // We copy the most recently changed rating on to these indicator-only
    // rating bars
    mIndicatorRatingBar = (RatingBar) findViewById(R.id.indicator_ratingbar);
    mSmallRatingBar = (RatingBar) findViewById(R.id.small_ratingbar);
    
    // The different rating bars in the layout. Assign the listener to us.
    ((RatingBar)findViewById(R.id.ratingbar1)).setOnRatingBarChangeListener(this);
    ((RatingBar)findViewById(R.id.ratingbar2)).setOnRatingBarChangeListener(this);
}
 
Example #5
Source File: LocationFragment.java    From foodie-app with Apache License 2.0 6 votes vote down vote up
public ViewHolder(View view,int viewType,MyItemClickListener myItemClickListener) {
    super(view);
    mView = view;
    mViewType=viewType;
    mItemClickListener = myItemClickListener;
    if (viewType == IS_HEADER) {
        headerView = (TextView) view.findViewById(R.id.my_location);
        headerView.setText("正在获取你的当前位置...");
        headerView.setOnClickListener(this);
        return;
    }
    mRestaurantImageView= (ImageView) view.findViewById(R.id.restaurant_image);
    mRestaurantNameView= (TextView) view.findViewById(R.id.restaurant_name_text);
    mScoreView= (RatingBar) view.findViewById(R.id.rating_bar);
    mCommentCountView= (TextView) view.findViewById(R.id.comment_count);
    mAveragePriceView= (TextView) view.findViewById(R.id.average_price);
    mKeywordView= (TextView) view.findViewById(R.id.keyword);
    mAddressVview= (TextView) view.findViewById(R.id.location);
    mDistanceView= (TextView) view.findViewById(R.id.distance);
    mItemClickListener=myItemClickListener;
    view.setOnClickListener(this);
}
 
Example #6
Source File: TrainingOverviewAdapter.java    From privacy-friendly-pedometer with GNU General Public License v3.0 6 votes vote down vote up
public TrainingSessionViewHolder(View v) {
    super(v);
    view = v;
    mCardViewLayout = (CardView) v.findViewById(R.id.card_training_session);
    mSmallLayout = (RelativeLayout) v.findViewById(R.id.card_training_session_small);
    mExpandedLayout = (LinearLayout) v.findViewById(R.id.card_training_session_expanded);
    mTextViewName = (TextView) v.findViewById(R.id.training_card_title);
    mTextViewDescription = (TextView) v.findViewById(R.id.training_card_description);
    mTextViewSteps = (TextView) v.findViewById(R.id.training_card_steps);
    mTextViewDistance = (TextView) v.findViewById(R.id.training_card_distance);
    mTextViewCalories = (TextView) v.findViewById(R.id.training_card_calories);
    mTextViewDuration = (TextView) v.findViewById(R.id.training_card_duration);
    mTextViewSmallSteps = (TextView) v.findViewById(R.id.training_small_card_steps);
    mTextViewSmallDuration = (TextView) v.findViewById(R.id.training_small_card_duration);
    mTextViewSmallDistance = (TextView) v.findViewById(R.id.training_small_card_distance);
    mTextViewSmallName = (TextView) v.findViewById(R.id.training_small_card_name);
    mTextViewDistanceTitle = (TextView) v.findViewById(R.id.distanceTitle);
    mTextViewSmallDistanceTitle = (TextView) v.findViewById(R.id.distance_title_small);
    mTextViewCaloriesTitle = (TextView) v.findViewById(R.id.calorieTitle);
    mRatingBarFeeling = (RatingBar) v.findViewById(R.id.training_card_feeling);
    mImageButton = (ImageButton) v.findViewById(R.id.training_card_menu);
    mImageButton.setOnClickListener(this);
    view.setOnClickListener(this);
}
 
Example #7
Source File: MovieDetailFragment.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void showVoteAverage(float voteAverage) {
    textViewVoteCount.setVisibility(View.VISIBLE);
    RatingBar newRatingBar = new RatingBar(new ContextThemeWrapper(getActivity(), R.style.RatingBarAccent));
    newRatingBar.setRating(voteAverage / 2);
    newRatingBar.setIsIndicator(true);
    newRatingBar.setOnRatingBarChangeListener(onRatingBarChangeListener);
    ((ViewGroup) ratingBarVoteAverage.getParent()).addView(newRatingBar, 0);
    ((ViewGroup) ratingBarVoteAverage.getParent()).removeView(ratingBarVoteAverage);
    ratingBarVoteAverage = newRatingBar;
}
 
Example #8
Source File: ProductRecommentationActivity.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
            RatingBar product_rating_bar = (RatingBar) mView.findViewById(R.id.product_rating_bar);
            product_rating_bar.setVisibility(View.GONE);
//            SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(itemView.getContext());
//            boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
//            if (ratingDisplayCheck == false)
//                product_rating_bar.setVisibility(View.INVISIBLE);
//            Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
        }
 
Example #9
Source File: ReviewDialogFragment.java    From SmileEssence with MIT License 5 votes vote down vote up
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View view = getActivity().getLayoutInflater().inflate(R.layout.dialog_review, null);
    ratingBar = (RatingBar) view.findViewById(R.id.rating_review);
    Button button = (Button) view.findViewById(R.id.button_submit);
    button.setOnClickListener(this);
    return new AlertDialog.Builder(getActivity())
            .setView(view)
            .create();
}
 
Example #10
Source File: AppInfosHolder.java    From miappstore with Apache License 2.0 5 votes vote down vote up
@Override
public View initView() {
    View view = View.inflate(UiUtils.getContext(), R.layout.holder_appinfos, null);
    tv_name = (TextView) view.findViewById(R.id.tv_appname);
    iv_icon = (ImageView) view.findViewById(R.id.iv_icon);
    rb_score = (RatingBar) view.findViewById(R.id.rb_score);
    tv_size_publisher = (TextView) view.findViewById(R.id.tv_size_publisher);
    return view;
}
 
Example #11
Source File: MediaItemsAdapter.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
public ViewHolderCardItem(View view) {
    super(view);
    this.imgSquare = (ImageViewSquare) view.findViewById(R.id.imgSquare);
    this.tvItemStatus = (TextView) view.findViewById(R.id.tvItemStatus);
    this.tvSquareTitle = (TextView) view.findViewById(R.id.tvSquareTitle);
    this.tvSquareSubTitle = (TextView) view.findViewById(R.id.tvSquareSubTitle);
    this.tvItemCount = (TextView) view.findViewById(R.id.tvItemCount);
    this.rbMediaItem = (RatingBar) view.findViewById(R.id.rbMediaItem);
    this.cvSquare = (CardView) view;
    Context context = view.getContext();
    LayerDrawable stars = (LayerDrawable) rbMediaItem.getProgressDrawable();
    stars.getDrawable(2).setColorFilter(context.getResources().getColor(R.color.starFullySelected), PorterDuff.Mode.SRC_ATOP);
    stars.getDrawable(1).setColorFilter(context.getResources().getColor(R.color.starPartiallySelected), PorterDuff.Mode.SRC_ATOP);
    stars.getDrawable(0).setColorFilter(context.getResources().getColor(R.color.starNotSelected), PorterDuff.Mode.SRC_ATOP);
}
 
Example #12
Source File: MainActivity.java    From android-basic-samples with Apache License 2.0 5 votes vote down vote up
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
  mSaveGame.setLevelStars(mWorld, mLevel, (int) rating);
  updateUi();
  findViewById(R.id.screen_gameplay).setVisibility(View.GONE);
  findViewById(R.id.screen_main).setVisibility(View.VISIBLE);

  mInLevel = false;
  // save new data to cloud
  saveSnapshot(null);
}
 
Example #13
Source File: ResultRecyclerAdapter.java    From KinoCast with MIT License 5 votes vote down vote up
ViewHolder(View itemView) {
    super(itemView);
    background = itemView.findViewById(R.id.layoutInfo);
    image = (ImageView) itemView.findViewById(R.id.image);
    title = (TextView) itemView.findViewById(R.id.title);
    language = (ImageView) itemView.findViewById(R.id.language);
    rating = (RatingBar) itemView.findViewById(R.id.rating);
    detail = (TextView) itemView.findViewById(R.id.detail);
    progressBar = (ProgressBar) itemView.findViewById(R.id.progressBar);
    image.setVisibility(View.GONE);
}
 
Example #14
Source File: KinoListAdapter.java    From CineLog with GNU General Public License v3.0 5 votes vote down vote up
private void initRating(View convertView, RatingBar kinoRatingRatingBar, KinoDto movie) {
    TextView kinoRatingRatingBarAsText = (TextView) convertView.findViewById(R.id.main_result_kino_rating_bar_as_text);
    TextView kinoRatingRatingBarMaxAsText = (TextView) convertView.findViewById(R.id.main_result_kino_rating_bar_max_as_text);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

    int maxRating;
    if (movie.getMaxRating() == null) {
        String defaultMaxRateValue = prefs.getString("default_max_rate_value", "5");
        maxRating = Integer.parseInt(defaultMaxRateValue);
    } else {
        maxRating = movie.getMaxRating();
    }

    if (maxRating <= 5) {
        kinoRatingRatingBarAsText.setVisibility(View.INVISIBLE);
        kinoRatingRatingBarMaxAsText.setVisibility(View.INVISIBLE);
        kinoRatingRatingBar.setVisibility(View.VISIBLE);

        kinoRatingRatingBar.setStepSize(0.5f);
        kinoRatingRatingBar.setNumStars(maxRating);

        if (movie.getRating() != null) {
            kinoRatingRatingBar.setRating(movie.getRating());
        } else {
            kinoRatingRatingBar.setRating(0);
        }
    } else {
        kinoRatingRatingBar.setVisibility(View.INVISIBLE);
        kinoRatingRatingBarAsText.setVisibility(View.VISIBLE);
        kinoRatingRatingBarMaxAsText.setVisibility(View.VISIBLE);

        kinoRatingRatingBarAsText.setText(String.format("%s", movie.getRating()));
        kinoRatingRatingBarMaxAsText.setText(String.format("/%s", maxRating));
    }
}
 
Example #15
Source File: Activity_FoodsDetails.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
private void initView() {
    nf = NumberFormat.getCurrencyInstance();
    nf.setMaximumFractionDigits(2);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.collapsing_toolbar);
    foods_imageView = (ImageView) findViewById(R.id.foods_image_view);
    foods_ingredients_text = (TextView) findViewById(R.id.foods_ingredients_text);
    foods_description_text = (TextView) findViewById(R.id.foods_description_text);
    fab_comment = (FloatingActionButton) findViewById(R.id.fab_comment);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar);
    tv_price = (TextView) findViewById(R.id.tv_price);
    tv_count = (TextView) findViewById(R.id.tvCount);
    tvMinus = (TextView) findViewById(R.id.tvMinus);
    tvAdd = (TextView) findViewById(R.id.tvAdd);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    collapsingToolbar.setTitle(name);

    Glide.with(this).load(imageUrl).into(foods_imageView);
    tv_price.setText(nf.format(price));
    tv_count.setText(count + "");
    foods_ingredients_text.setText("配料:" + ingredients);
    foods_description_text.setText("简介:" + description);
    ratingBar.setProgress(rating);

    tvMinus.setOnClickListener(this);
    tvAdd.setOnClickListener(this);
    fab_comment.setOnClickListener(this);
}
 
Example #16
Source File: Review.java    From YalpStore with GNU General Public License v2.0 5 votes vote down vote up
public void clearUserReview() {
    ((RatingBar) activity.findViewById(R.id.user_stars)).setRating(0);
    setText(R.id.user_title, "");
    setText(R.id.user_comment, "");
    setText(R.id.rate, R.string.details_rate_this_app);
    activity.findViewById(R.id.user_review_edit_delete).setVisibility(View.GONE);
    activity.findViewById(R.id.user_review).setVisibility(View.GONE);
}
 
Example #17
Source File: InfoBarControlLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Creates and adds a control that shows a review rating score.
 *
 * @param rating Fractional rating out of 5 stars.
 */
public View addRatingBar(float rating) {
    View ratingLayout = LayoutInflater.from(getContext()).inflate(
            R.layout.infobar_control_rating, this, false);
    addView(ratingLayout, new ControlLayoutParams());

    RatingBar ratingView = (RatingBar) ratingLayout.findViewById(R.id.control_rating);
    ratingView.setRating(rating);
    return ratingView;
}
 
Example #18
Source File: VisualUtil.java    From sa-sdk-android with Apache License 2.0 5 votes vote down vote up
public static boolean isSupportClick(View v) {
    ViewParent parent = v.getParent();
    if (parent instanceof AdapterView || ViewUtil.instanceOfRecyclerView(parent)) {
        return true;
    }
    if (v instanceof RatingBar || v instanceof SeekBar) {
        return true;
    }
    return false;
}
 
Example #19
Source File: MovieInterestListAdapter.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);
    imageViewMoviePoster = (ImageView) itemView.findViewById(R.id.imageview_movieposter);
    textViewMovieName = (TextView) itemView.findViewById(R.id.textview_moviename);
    textViewMovieReleaseDate = (TextView) itemView.findViewById(R.id.textview_moviereleasedate);
    textViewMovieVoteCount = (TextView) itemView.findViewById(R.id.textview_movievotecount);
    ratingBarVote = (RatingBar) itemView.findViewById(R.id.ratingbar_vote);
}
 
Example #20
Source File: Adapter_Comment.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
public ViewHolder(View itemView) {
    super(itemView);
    comment_item_view = itemView.findViewById(R.id.comment_item_view);

    food_img = (ImageView) itemView.findViewById(R.id.comment_food_img);
    tv_food_name = (TextView) itemView.findViewById(R.id.comment_food_name);
    tv_time = (TextView) itemView.findViewById(R.id.comment_time);
    ratingBar = (RatingBar) itemView.findViewById(R.id.comment_ratingBar);
    tv_content = (TextView) itemView.findViewById(R.id.comment_food_content);

}
 
Example #21
Source File: MartianViewHolder.java    From RxJava2RetrofitDemo with Apache License 2.0 5 votes vote down vote up
@Override
public MartianViewHolder setRating(int viewId, float rating, int max) {
    RatingBar view = getView(viewId);
    view.setMax(max);
    view.setRating(rating);
    return this;
}
 
Example #22
Source File: MovieDetailFragment.java    From Movie-Check with Apache License 2.0 5 votes vote down vote up
@Override
public void showUserClassification(Float classification) {
    textViewVoteCount.setVisibility(View.INVISIBLE);
    RatingBar newRatingBar = new RatingBar(new ContextThemeWrapper(getActivity(), R.style.RatingBarRed));
    newRatingBar.setRating(classification);
    newRatingBar.setIsIndicator(false);
    newRatingBar.setOnRatingBarChangeListener(onRatingBarChangeListener);
    ((ViewGroup) ratingBarVoteAverage.getParent()).addView(newRatingBar, 0);
    ((ViewGroup) ratingBarVoteAverage.getParent()).removeView(ratingBarVoteAverage);
    ratingBarVoteAverage = newRatingBar;

}
 
Example #23
Source File: ViewFinderImpl.java    From RendererRecyclerViewAdapter with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
@NonNull
@Override
public ViewFinder setMinRating(final int ID, final int min) {
	((RatingBar) find(ID)).setMin(min);
	return this;
}
 
Example #24
Source File: ViewFinderImpl.java    From RendererRecyclerViewAdapter with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public ViewFinder setRating(final int ID, final float rating, final int max) {
	final RatingBar ratingBar = find(ID);
	ratingBar.setRating(rating);
	ratingBar.setMax(max);
	return this;
}
 
Example #25
Source File: ViewFinderImpl.java    From RendererRecyclerViewAdapter with Apache License 2.0 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.O)
@NonNull
@Override
public ViewFinder setRating(final int ID, final float rating, final int min, final int max) {
	final RatingBar ratingBar = find(ID);
	ratingBar.setRating(rating);
	ratingBar.setMin(min);
	ratingBar.setMax(max);
	return this;
}
 
Example #26
Source File: ViewHolder.java    From baseAdapter with Apache License 2.0 5 votes vote down vote up
public ViewHolder setRating(int viewId, float rating, int max)
{
    RatingBar view = getView(viewId);
    view.setMax(max);
    view.setRating(rating);
    return this;
}
 
Example #27
Source File: FavouriteProductFragment.java    From FaceT with Mozilla Public License 2.0 5 votes vote down vote up
public void setRating(Long rating) {
    RatingBar product_rating_bar = (RatingBar) mFavouriteProductView.findViewById(R.id.favourite_product_rating_bar);
    product_rating_bar.setRating(rating);
    SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(mFavouriteProductView.getContext());
    boolean ratingDisplayCheck = SP.getBoolean("ratingButton", true);
    if(ratingDisplayCheck == false)
        product_rating_bar.setVisibility(View.INVISIBLE);
    Log.d(TAG + " ratingDisplayCheck", ratingDisplayCheck + "");
}
 
Example #28
Source File: DetailActivity.java    From JsonParsingDemo with MIT License 5 votes vote down vote up
private void setUpUIViews() {
    ivMovieIcon = (ImageView)findViewById(R.id.ivIcon);
    tvMovie = (TextView)findViewById(R.id.tvMovie);
    tvTagline = (TextView)findViewById(R.id.tvTagline);
    tvYear = (TextView)findViewById(R.id.tvYear);
    tvDuration = (TextView)findViewById(R.id.tvDuration);
    tvDirector = (TextView)findViewById(R.id.tvDirector);
    rbMovieRating = (RatingBar)findViewById(R.id.rbMovie);
    tvCast = (TextView)findViewById(R.id.tvCast);
    tvStory = (TextView)findViewById(R.id.tvStory);
    progressBar = (ProgressBar)findViewById(R.id.progressBar);
}
 
Example #29
Source File: AppCommentController.java    From Bailan with Apache License 2.0 5 votes vote down vote up
private void init() {
    contentView = UIUtils.inflate(R.layout.appdetail_comment_score);
    commentScore = (TextView) contentView.findViewById(R.id.app_comment_score_textview);
    commentStars = (RatingBar) contentView.findViewById(R.id.detail_comment_colligation_stars_ratingbar);
    commentCount = (TextView) contentView.findViewById(R.id.detail_comments_count_textview);
    fiveStarsProgressBar = (ProgressBar) contentView.findViewById(R.id.detail_comment_five_stars_proportion_progressbar);
    fourStarsProgressBar = (ProgressBar) contentView.findViewById(R.id.detail_comment_four_stars_proportion_progressbar);
    threeStarsProgressBar = (ProgressBar) contentView.findViewById(R.id.detail_comment_three_stars_proportion_progressbar);
    twoStarsProgressBar = (ProgressBar) contentView.findViewById(R.id.detail_comment_two_stars_proportion_progressbar);
    oneStarsProgressBar = (ProgressBar) contentView.findViewById(R.id.detail_comment_one_stars_proportion_progressbar);
}
 
Example #30
Source File: TVShowAdapter.java    From android with Apache License 2.0 5 votes vote down vote up
private ViewHolder(View convertView) {
    mTitle = (TextView) convertView.findViewById(R.id.text1);
    mGenres = (TextView) convertView.findViewById(R.id.text2);
    mYear = (TextView) convertView.findViewById(R.id.text3);
    mRating = (RatingBar) convertView.findViewById(R.id.rating_bar1);
    mImageView = (ImageView) convertView.findViewById(R.id.image1);
}