評価の整数値を取得しているため、評価を 1 ずつ更新するコードに基づいてコードを記述しようとしています。ここに同じコードがあります
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginRight="3dp" >
<RatingBar
android:id="@+id/PriceRating"
style="@style/foodRatingBarSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:isIndicator="true"
android:numStars="1"
android:stepSize="0.25"
android:max="5" />
</LinearLayout>
スタイル ファイル内のコードは次のとおりです。
<style name="foodRatingBarSmall" parent="@android:style/Widget.RatingBar">
<item name="android:progressDrawable">@drawable/foodratingbar_full</item>
<item name="android:minHeight">20dip</item>
<item name="android:maxHeight">20dip</item>
</style>
これがfoodratingbarファイルです
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/background" android:drawable="@drawable/foodratingbar_fill"
/>
<item android:id="@+id/secondaryProgress"
android:drawable="@drawable/foodratingbar_fill" />
<item android:id="@+id/progress" android:drawable="@drawable/foodratingbar_empty" />
</layer-list>
foodratingbar_fill のコードは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:state_window_focused="true"
android:drawable="@drawable/dollar" />
<item android:state_focused="true"
android:state_window_focused="true"
android:drawable="@drawable/dollar" />
<item android:state_selected="true"
android:state_window_focused="true"
android:drawable="@drawable/dollar" />
<item android:drawable="@drawable/dollar" />
</selector>
ドルはpng画像です
私のコードの問題は、必要な数の星に更新することができず、アンドロイドに表示されている星の数のあいまいな値が表示されることです。最大 5 の評価で 1 ドルの画像を表示する方法を知りたい