1024programmer News Analysis of SeekBar and RatingBar usage examples in Android

Analysis of SeekBar and RatingBar usage examples in Android

This article describes the usage of SeekBar and RatingBar in Android. Share it with everyone for your reference, as follows:

What is a SeekBar?

A progress bar that can be dragged (most commonly used in the player)

1. Declare in the layout file

2. Define an OnSeekBarChangeListener and override the three methods

SeekBar seekBar = (SeekBar)findViewById(R.id.seekBar);
 seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
   @Override
   public void onStopTrackingTouch(SeekBar seekBar) {
     System.out.println("onStopTrackingTouch");
   }
   @Override
   public void onStartTrackingTouch(SeekBar seekBar) {
     System.out.println("onStartTrackingTouch");
   }
   @Override
   public void onProgressChanged(SeekBar seekBar, int progress,
       boolean fromUser) {
     System.out.println("progress : " + progress);
   }
 });

What is the Rating Bar?

Review level (show many stars)

1. Declare RatingBar in the layout file

2. Define an OnRatingBarChangeListener

RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar);
 ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
   @Override
   public void onRatingChanged(RatingBar ratingBar, float rating,
       boolean fromUser) {
     System.out.println(rating);
   }
 });

I hope this article will help everyone in Android programming design.

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/analysis-of-seekbar-and-ratingbar-usage-examples-in-android/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索