@Override protected void applyTransformation(float interpolatedTime, Transformation t) { int progress = Math.round(interpolatedTime * mDecimalRatingBars[0].getMax()); for (RatingBar ratingBar : mDecimalRatingBars) { ratingBar.setProgress(progress); } }
@Override public View getItemView(int section, int position, View convertView, ViewGroup parent) { LinearLayout layout; if (convertView == null) { LayoutInflater inflator = (LayoutInflater) parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); layout = (LinearLayout) inflator.inflate(R.layout.item_survey, null); } else { layout = (LinearLayout) convertView; } ((TextView) layout.findViewById(R.id.questionSurvey)).setText(surveyBeans.get(section).get(position).getQuestion()); RatingBar ratingBar = ((RatingBar) layout.findViewById(R.id.ratingBar)); ratingBar.setProgress(Integer.parseInt(surveyBeans.get(section).get(position).getRate())); if (ratingBar.getRating() == 2f) { //change color of two stars } else if (ratingBar.getRating() == 3f) { //change color of three stars } LayerDrawable stars = (LayerDrawable) ratingBar.getProgressDrawable(); stars.getDrawable(2).setColorFilter(Color.YELLOW, PorterDuff.Mode.SRC_ATOP); stars.getDrawable(1).setColorFilter(Color.RED, PorterDuff.Mode.SRC_ATOP); ((TextView) layout.findViewById(R.id.commentSurvey)).setText(surveyBeans.get(section).get(position).getComment()); return layout; }
LinearLayout ll = (LinearLayout)findViewById(R.id.ll); ViewGroup parentGroup = parentGroup = (ViewGroup)ll; for (int i = 0; i < 3; i++) { LayoutInflater inflater = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view = inflater.inflate(R.layout.element_list_item, null, true); RatingBar rBar = (RatingBar)view.findViewById(R.id.ratingBar1); rBar.setProgress(i); parentGroup.addView(view); }
public void createParseQuery(final int markerId) { ParseQueryAdapter.QueryFactory<CommentPost> queryAdapterFactory = new ParseQueryAdapter.QueryFactory<CommentPost>() { public ParseQuery<CommentPost> create() { ParseQuery<CommentPost> parseQuery = CommentPost.getQuery(); parseQuery.whereEqualTo("markerId", markerId); parseQuery.include("user"); parseQuery.orderByDescending("createdAt"); return parseQuery; } }; queryAdapter = new ParseQueryAdapter<CommentPost>(this, queryAdapterFactory) { @Override public View getItemView(CommentPost post, View view, ViewGroup parent) { if (view == null) { view = View.inflate(getContext(), R.layout.item_comment_post, null); } TextView textViewPostUsername = (TextView) view .findViewById(R.id.textViewPostUsername); TextView textViewPostComment = (TextView) view .findViewById(R.id.textViewPostComment); RatingBar ratingBarPostRating = (RatingBar) view .findViewById(R.id.ratingBarPostRating); textViewPostUsername.setText(post.getUser().getUsername()); textViewPostComment.setText(post.getComment()); ratingBarPostRating.setProgress(post.getRating()); return view; } };
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.container); RatingBar rate = new RatingBar(this); rate.setRating(2); rate.setNumStars(4); rate.setProgress(1); rate.setLayoutParams(new FrameLayout.LayoutParams( FrameLayout.LayoutParams.WRAP_CONTENT, FrameLayout.LayoutParams.WRAP_CONTENT)); frameLayout.addView(rate);