Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why is my rating bar not changing on user touch?

I have tried to add a rating bar to my activity

but I cannot add or remove stars on user's touch.

what should i add?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <TextView
            android:id="@+id/TextView01"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/feedback" />
    </LinearLayout>

    <View
        android:layout_width="wrap_content"
        android:layout_height="30dp" />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="10dp" >

        <RatingBar
            android:id="@+id/serviceRatingBar"
            style="?android:attr/ratingBarStyleIndicator"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true" />

        <TextView
            android:id="@+id/price"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_centerVertical="true"
            android:text="@string/service" />
    </RelativeLayout>


    <LinearLayout 
                 android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
        >
           <Button
        android:id="@+id/sendBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/send" />

        <Button
        android:id="@+id/cancelBtn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/cancel" />


    </LinearLayout>

</LinearLayout>
like image 492
Elad Benda2 Avatar asked Nov 30 '22 00:11

Elad Benda2


1 Answers

Your RatingBar style is set to be indicator

style="?android:attr/ratingBarStyleIndicator"

which prevent user inter action, try to set android:isIndicator="false" manually, if it didn't work try changing its style to

style="?android:attr/ratingBarStyle"
like image 168
Ahmad Dwaik 'Warlock' Avatar answered Dec 04 '22 13:12

Ahmad Dwaik 'Warlock'