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.