Too easy to use , just see:
package com.progressbar_test03; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.View; import android.widget.RatingBar; import android.widget.SeekBar; public class BarTest extends Activity { private SeekBar seekbar; private RatingBar ratingbar; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); seekbar=(SeekBar)this.findViewById(R.id.seekbar); seekbar.setMax(100); seekbar.setOnSeekBarChangeListener(seekListener); ratingbar=(RatingBar)this.findViewById(R.id.ratingbar); ratingbar.setOnRatingBarChangeListener(ratingListener); } private SeekBar.OnSeekBarChangeListener seekListener=new SeekBar.OnSeekBarChangeListener() { public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) { // throw new UnsupportedOperationException("Not supported yet."); Log.i("l","onProgressChanged:"+bar+",progress:"+progress+",from user:"+fromUser); } public void onStartTrackingTouch(SeekBar bar) { // throw new UnsupportedOperationException("Not supported yet."); Log.i("l","onSatrtTrackingTouch"); } public void onStopTrackingTouch(SeekBar bar) { // throw new UnsupportedOperationException("Not supported yet."); Log.i("l","onStopTrackingTouch"); } }; private RatingBar.OnRatingBarChangeListener ratingListener=new RatingBar.OnRatingBarChangeListener() { public void onRatingChanged(RatingBar bar, float rating, boolean fromUser) { // throw new UnsupportedOperationException("Not supported yet."); Log.i("l", "onRatingChanged:"+bar+", rating:"+rating+", fromUser:"+fromUser); } }; }
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Hello World, BarTest" /> <SeekBar android:id="@+id/seekbar" android:layout_width="fill_parent" android:layout_height="wrap_content" /> <RatingBar android:id="@+id/ratingbar" android:layout_width="wrap_content" android:layout_height="wrap_content" android:numStars="5" android:stepSize="1" /> </LinearLayout>