Search code examples
androidratingbar

Android RatingBar


I'm new to android development
I need to create a RatingBar that shows rating according to Application details .
My App calculate a value according to user input and it will be shown in RatingBar .
That bar only shows the value (eg. 4/5 stars ) according to the calculated value
I need to create it that users can't change RatingBar's value directly .They only enter the input and that input calculate some value and that value need to be displayed in RatingBar.

Can you please help me to do this? This is the only way than I can think of using RatingBar (according to my knowledge).


Solution

  • Try this out.I think this will solve your problem

    This is java code

    RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar1);
    ratingBar.setOnTouchListener(new OnTouchListener() {
            public boolean onTouch(View v, MotionEvent event) {
                return true;
            }
        });
    

    XML code

    <RatingBar
    
             android:id="@+id/ratingBar1"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content" 
             android:numStars="5"
             android:progress="30"
             android:clickable="false"     
             android:focusableInTouchMode="false"    
             android:focusable="false"
    
            />