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);
}
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 = findViewById(R.id.textView);
final RatingBar bar = 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(getString(R.string.rating_string, rating));
}
});
}
use of android.widget.RatingBar in project philm by chrisbanes.
the class RateMovieFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
View layout = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_rate_movie, null);
mMarkMovieWatchedCheckbox = (CheckBox) layout.findViewById(R.id.checkbox_mark_watched);
mRatingDescriptionTextView = (TextView) layout.findViewById(R.id.textview_rating_desc);
mRatingBar = (RatingBar) layout.findViewById(R.id.ratingbar_rating);
mRatingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
updateRatingDescriptionText();
}
});
mRatingBar.setEnabled(mMovie != null);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setView(layout);
builder.setPositiveButton(R.string.movie_detail_rate, this);
builder.setNegativeButton(android.R.string.cancel, this);
return builder.create();
}
use of android.widget.RatingBar in project QuickAndroid by ImKarl.
the class BaseAdapterHelper 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 BaseAdapterHelper for chaining.
*/
@SuppressWarnings("unchecked")
public H setRating(int viewId, float rating, int max) {
RatingBar view = retrieveView(viewId);
view.setMax(max);
view.setRating(rating);
return (H) this;
}
use of android.widget.RatingBar in project aware-client by denzilferreira.
the class ESM_Likert method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
super.onCreateDialog(savedInstanceState);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View ui = inflater.inflate(R.layout.esm_likert, null);
builder.setView(ui);
esm_dialog = builder.create();
esm_dialog.setCanceledOnTouchOutside(false);
try {
TextView esm_title = (TextView) ui.findViewById(R.id.esm_title);
esm_title.setText(getTitle());
TextView esm_instructions = (TextView) ui.findViewById(R.id.esm_instructions);
esm_instructions.setText(getInstructions());
final RatingBar ratingBar = (RatingBar) ui.findViewById(R.id.esm_likert);
ratingBar.setNumStars(getLikertMax());
ratingBar.setMax(getLikertMax());
ratingBar.setStepSize((float) getLikertStep());
ratingBar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
TextView min_label = (TextView) ui.findViewById(R.id.esm_min);
min_label.setText(getLikertMinLabel());
TextView max_label = (TextView) ui.findViewById(R.id.esm_max);
max_label.setText(getLikertMaxLabel());
Button cancel = (Button) ui.findViewById(R.id.esm_cancel);
cancel.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
esm_dialog.cancel();
}
});
Button submit = (Button) ui.findViewById(R.id.esm_submit);
submit.setText(getSubmitButton());
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try {
if (getExpirationThreshold() > 0 && expire_monitor != null)
expire_monitor.cancel(true);
ContentValues rowData = new ContentValues();
rowData.put(ESM_Provider.ESM_Data.ANSWER_TIMESTAMP, System.currentTimeMillis());
rowData.put(ESM_Provider.ESM_Data.ANSWER, ratingBar.getRating());
rowData.put(ESM_Provider.ESM_Data.STATUS, ESM.STATUS_ANSWERED);
getContext().getContentResolver().update(ESM_Provider.ESM_Data.CONTENT_URI, rowData, ESM_Provider.ESM_Data._ID + "=" + getID(), null);
Intent answer = new Intent(ESM.ACTION_AWARE_ESM_ANSWERED);
answer.putExtra(ESM.EXTRA_ANSWER, rowData.getAsString(ESM_Provider.ESM_Data.ANSWER));
getActivity().sendBroadcast(answer);
if (Aware.DEBUG)
Log.d(Aware.TAG, "Answer:" + rowData.toString());
esm_dialog.dismiss();
} catch (JSONException e) {
e.printStackTrace();
}
}
});
} catch (JSONException e) {
e.printStackTrace();
}
return esm_dialog;
}
Aggregations