![RatingBar RatingBar](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgd928pHQOANGM_BxSxNSiu7Bgjuy2_da7LEOvWk4J7mZxzJacwKUHqbCQJHBypIGou4vnOwwA3d0eqfmGp8_nKHWUF-2J3B2nrrAw6hOMav5OLLYL_vwIbK_YRRew8FzHACIjqlZYTkC3S/s400/RatingBar.png)
main.xml
<?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="@string/hello"
/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleIndicator"
android:id="@+id/ratingbar_Indicator"
/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyleSmall"
android:id="@+id/ratingbar_Small"
android:numStars="20"
/>
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/ratingBarStyle"
android:id="@+id/ratingbar_default"
/>
</LinearLayout>
AndroidRatingBar.java
package com.AndroidRatingBar;
import android.app.Activity;
import android.os.Bundle;
import android.widget.RatingBar;
import android.widget.Toast;
public class AndroidRatingBar extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final RatingBar ratingBar_Small = (RatingBar)findViewById(R.id.ratingbar_Small);
final RatingBar ratingBar_Indicator = (RatingBar)findViewById(R.id.ratingbar_Indicator);
final RatingBar ratingBar_default = (RatingBar)findViewById(R.id.ratingbar_default);
ratingBar_default.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){
@Override
public void onRatingChanged(RatingBar ratingBar, float rating,
boolean fromUser) {
// TODO Auto-generated method stub
ratingBar_Small.setRating(rating);
ratingBar_Indicator.setRating(rating);
Toast.makeText(AndroidRatingBar.this, "rating:"+String.valueOf(rating),
Toast.LENGTH_LONG).show();
}});
}
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi8p8OYSJ34x9VZ9cj4IzAOVtRlBOzcLrPRJWQ4iuiJI1eCKjrLYOEL2p2RYTNBidfvJuDOpoiZjXICYCF5ifVUBp09IMGbHsHFSOko1_Xdf4gYrG9MbcBSZDywv5SWAQhCav5OT9OGPE5T/s200/icons_download.gif)