0

i want to place a rating bar in my application which is used to give rating for a specific product. i have used the small ratings bar style. after doing that, when i run the application, i am unable to set the ratings bar upon touching the stars.

My code is:

<RatingBar
        android:id="@+id/ratingBar1"
        style="?android:attr/ratingBarStyleSmall"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:clickable="false"
        android:focusable="false"
        android:focusableInTouchMode="false"
        android:progress="30"
         />

the code for oncreate method is:

    protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.feedback_layout);


    OnRatingBarChangeListener rbListener = new OnRatingBarChangeListener() {

        @Override
        public void onRatingChanged(RatingBar arg0, float arg1, boolean arg2) {
            // TODO Auto-generated method stub
                            //Code here

        }
    };
    final RatingBar rb = (RatingBar)findViewById(R.id.RatingBar01);
    rb.setOnRatingBarChangeListener(rbListener);

}
Gaurav Sood
  • 157
  • 3
  • 16

1 Answers1

0

change your xml to:

<RatingBar
    android:id="@+id/ratingBar1"
    style="?android:attr/ratingBarStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:numStars="5"
    android:rating="5" />

but anyhow, small rating bar makes it hard to interact with and to rate. have a look at this

Community
  • 1
  • 1
Soheil
  • 1,676
  • 7
  • 34
  • 65