@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_seek_bar); SeekBar sb = (SeekBar) findViewById(R.id.seekBar); sb.setMax(100); sb.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { Log.e("aaa", progress + ""); } @Override public void onStartTrackingTouch(SeekBar seekBar) { // Toast.makeText(trySeekBar.this, "SeekBar START", Toast.LENGTH_SHORT).show(); } @Override public void onStopTrackingTouch(SeekBar seekBar) { // Toast.makeText(trySeekBar.this, "SeekBar END", Toast.LENGTH_SHORT).show(); } }); RatingBar rb = (RatingBar) findViewById(R.id.ratingBar); rb.setMax(5); rb.setOnRatingBarChangeListener( new RatingBar.OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { Toast.makeText(trySeekBar.this, rating + "", Toast.LENGTH_SHORT).show(); } }); }
// ** Called when the activity is first created. *//* @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); // 隐藏标题 getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); // 设置全屏 nameHeaderUrlList = new ArrayList<NameHeaderUrlPair>(); if (apiKey == null || apiSecret == null) { Util.showAlert(this, "警告", "人人应用的apiKey和apiSecret必须提供!"); } setContentView(R.layout.main); ratingBar = (RatingBar) findViewById(R.id.levelBar); ratingBar.setMax(6); ratingBar.setNumStars(3); ratingBar.setStepSize((float) 0.5); ratingBar.setRating((float) 1.5); initialRenRen(); /*Spinner s = (Spinner) findViewById(R.id.friendNumerSpin); String []friendNumber=new String[]{"好友人数:10","好友人数:20","好友人数:50","所有好友"}; ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, friendNumber); s.setAdapter(adapter);*/ }
/** * Sets the step size (granularity) of this rating bar. * * @param stepSize The step size of this rating bar. For example, if half-star granularity is * wanted, this would be 0.5. */ public void setStepSize(float stepSize) { if (stepSize <= 0) { return; } final float newMax = mNumStars / stepSize; final int newProgress = (int) (newMax / getMax() * getProgress()); setMax((int) newMax); setProgress(newProgress); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); s1 = (SeekBar) findViewById(R.id.seekBar); s2 = (SeekBar) findViewById(R.id.seekBar2); growText = (TextView) findViewById(R.id.textView); rate = (RatingBar) findViewById(R.id.ratingBar); rate.setMax(fiveStars); // event listeners for the widgets s1.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { growText.setTextSize((float) progress / 3); } @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onStopTrackingTouch(SeekBar seekBar) {} }); s2.setOnSeekBarChangeListener( new SeekBar.OnSeekBarChangeListener() { @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { rate.setRating((float) progress / 15); } @Override public void onStartTrackingTouch(SeekBar seekBar) {} @Override public void onStopTrackingTouch(SeekBar seekBar) {} }); }
@Override public void setupInnerViewElements(ViewGroup parent, View view) { TextView title = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_title); title.setText("FREE"); TextView subtitle = (TextView) view.findViewById(R.id.carddemo_gplay_main_inner_subtitle); subtitle.setText(secondaryTitle); RatingBar mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_gplay_main_inner_ratingBar); mRatingBar.setNumStars(5); mRatingBar.setMax(5); mRatingBar.setStepSize(0.5f); mRatingBar.setRating(rating); }
@Override protected void onFinishInflate() { super.onFinishInflate(); ratingBar = (RatingBar) findViewById(R.id.zrb_rating); ratingTv = (TextView) findViewById(R.id.ztv_rating); ratingBar.setNumStars(numStars); ratingBar.setStepSize(stepSize); ratingBar.setMax(max); ratingBar.setRating(rating); ratingBar.setIsIndicator(isIndicator); ratingTv.setTextSize(mTextSize / getResources().getDisplayMetrics().density); ratingTv.setTextColor(mTextColor); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); layoutParams.setMargins(0, 0, mSpacing, 0); ratingBar.setLayoutParams(layoutParams); }
@Override public void setupInnerViewElements(ViewGroup parent, View view) { // Retrieve elements mTitle = (TextView) parent.findViewById(R.id.carddemo_myapps_main_inner_title); mSecondaryTitle = (TextView) parent.findViewById(R.id.carddemo_myapps_main_inner_secondaryTitle); mRatingBar = (RatingBar) parent.findViewById(R.id.carddemo_myapps_main_inner_ratingBar); if (mTitle != null) mTitle.setText(title); if (mSecondaryTitle != null) mSecondaryTitle.setText(secondaryTitle); if (mRatingBar != null) { mRatingBar.setNumStars(5); mRatingBar.setMax(5); mRatingBar.setStepSize(0.5f); mRatingBar.setRating(rating); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); Log.i(console_text, "Entered onCreateFunction"); FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); fab.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null) .show(); } }); textSize = (SeekBar) findViewById(R.id.seekBar); second = (SeekBar) findViewById(R.id.seekBar2); textToGrow = (TextView) findViewById(R.id.textgrow); rate = (RatingBar) findViewById(R.id.ratingBar); rate.setMax(FiveStar); }
public ViewHolder setRating(int viewId, float rating, int max) { RatingBar view = getView(viewId); view.setMax(max); view.setRating(rating); return this; }
/** * 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. */ public BaseRcvAdapterHelper setRating(int viewId, float rating, int max) { RatingBar view = retrieveView(viewId); view.setMax(max); view.setRating(rating); return this; }
public RecyclerViewHolder setRating(int viewId, float rating, int max) { RatingBar view = findViewById(viewId); view.setMax(max); view.setRating(rating); return this; }