RatingBar评星

<?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:id="@+id/textView1"    
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"    
  android:textSize="30dp" android:text="RatingBar测试">
    </TextView>
  <RatingBar android:id="@+id/ratingBar1"    
  android:layout_width="wrap_content"    
  android:layout_height="wrap_content" android:numStars="5" android:stepSize="0.5"></RatingBar>
</LinearLayout>
package com.SeekBarDemo;

import android.app.Activity;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener;

public class MainActivity extends Activity {
   /** Called when the activity is first created. */
  RatingBar ratingBar;

  @Override
   public void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    ratingBar = (RatingBar) findViewById(R.id.ratingBar1);
    ratingBar.setOnRatingBarChangeListener( new ratingBarListenner());
  }

   class ratingBarListenner implements OnRatingBarChangeListener {

     public void onRatingChanged(RatingBar ratingBar, float rating,
         boolean fromUser) {
       // TODO Auto-generated method stub
      System.out.println( "星级评分ratingBar" + rating);
    }

  }
}

你可能感兴趣的:(RatingBar评星)