Search in sources :

Example 21 with RatingBar

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);
    }
}
Also used : ViewHolder(xdroid.viewholder.ViewHolder) TextView(android.widget.TextView) RatingBar(android.widget.RatingBar) CompoundButton(android.widget.CompoundButton)

Example 22 with RatingBar

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;
}
Also used : RatingBar(android.widget.RatingBar)

Example 23 with RatingBar

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;
}
Also used : AlertDialog(android.app.AlertDialog) ContentValues(android.content.ContentValues) JSONException(org.json.JSONException) Intent(android.content.Intent) TextView(android.widget.TextView) View(android.view.View) RatingBar(android.widget.RatingBar) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) NonNull(android.support.annotation.NonNull)

Example 24 with RatingBar

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);
        }
    });
}
Also used : TextView(android.widget.TextView) ImageView(android.widget.ImageView) RatingBar(android.widget.RatingBar) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

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