主xml文件
java文件中
import android.os.Bundle;import android.app.Activity;import android.util.Log;import android.view.Menu;import android.widget.RatingBar;import android.widget.RatingBar.OnRatingBarChangeListener;import android.widget.SeekBar;import android.widget.SeekBar.OnSeekBarChangeListener;public class MainActivity extends Activity implements OnSeekBarChangeListener,OnRatingBarChangeListener{ private SeekBar seekBar = null; private RatingBar ratingBar = null; private static final String TAG="info"; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); seekBar = (SeekBar) findViewById(R.id.seekBar1); ratingBar = (RatingBar) findViewById(R.id.ratingBar1); seekBar.setOnSeekBarChangeListener(this); ratingBar.setOnRatingBarChangeListener(this); } @Override public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { Log.i(TAG, ""+progress); } @Override public void onStartTrackingTouch(SeekBar seekBar) { Log.i(TAG, ""+"StartTrackingTouch"); } @Override public void onStopTrackingTouch(SeekBar seekBar) { Log.i(TAG, "StopTrackingTouch"); } @Override public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) { Log.i(TAG, arg1+""); }}