use of android.widget.RatingBar in project xdroid by shamanland.
the class ExampleBinder method onNewData.
@Override
public void onNewData(int position, View view, ExampleData data) {
ViewHolder holder = ViewHolder.obtain(view);
TextView text1 = holder.get(android.R.id.text1);
if (text1 != null) {
text1.setText(data.getTitle());
}
TextView text2 = holder.get(android.R.id.text2);
if (text2 != null) {
text2.setText(data.getSubTitle());
}
CompoundButton added = holder.get(R.id.added);
if (added != null) {
added.setChecked(data.isAdded());
}
RatingBar progress = holder.get(android.R.id.progress);
if (progress != null) {
progress.setRating((Math.abs(data.hashCode()) % 5) + 1);
}
}
use of android.widget.RatingBar in project FastDev4Android by jiangqqlmj.
the class BaseAdapterHelper method setRating.
/**
* Sets the rating (the number of stars filled) of a RatingBar.
* 设置评分条的分数
* @param viewId The view id.
* @param rating The rating.
* @return The BaseAdapterHelper for chaining.
*/
public BaseAdapterHelper setRating(int viewId, float rating) {
RatingBar view = retrieveView(viewId);
view.setRating(rating);
return 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;
}
use of android.widget.RatingBar in project DevRing by LJYcoder.
the class MovieAdapter method bindDataForView_.
@Override
protected void bindDataForView_(ViewHolder holder, final MovieRes movieRes, int position) {
ImageView ivMovie = holder.getView(R.id.iv_movie);
TextView tvTitle = holder.getView(R.id.tv_title);
TextView tvType = holder.getView(R.id.tv_type);
TextView tvYear = holder.getView(R.id.tv_year);
RatingBar rbAverage = holder.getView(R.id.rb_average);
DevRing.imageManager().loadNet(movieRes.getImages().getMedium(), ivMovie);
tvTitle.setText(movieRes.getTitle());
String type = "";
for (String s : movieRes.getGenres()) {
type = type + s + "/";
}
tvType.setText(TextUtils.isEmpty(type) ? "暂无类型" : type.substring(0, type.length() - 1));
tvYear.setText(movieRes.getYear());
rbAverage.setRating(movieRes.getRating().getAverage() / 2);
holder.itemView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
movieRes.setMovieType(mMovieType);
DevRing.busManager().postEvent(movieRes);
}
});
}
Aggregations