我有一個谷歌地圖應用程序,用戶可以在他們通過標記選擇的餐廳中評分我在sq lite數據庫中存儲了該評分值,當他們點擊視圖評分時按鈕我在滾動視圖中顯示字符串的名稱和評分值。 現在我想要顯示星星的評分值,即用戶輸入的方式。 如何顯示存儲在數據庫中的星星數量
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:text="Rate me"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:id="@+id/rateme"
android:layout_weight="0.00" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="Restaurent Name"
android:ems="10"
android:id="@+id/place"
android:layout_weight="0.00" />
<RatingBar
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:stepSize="1.0"
android:rating="2.0"
android:layout_marginTop="64dp"
android:layout_below="@+id/place"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="@+id/rate"
android:layout_weight="0.00" />
<Button
android:text="Submit"
android:layout_width="395dp"
android:layout_height="wrap_content"
android:id="@+id/submit"
android:onClick="insert"/>
<Button
android:text="view Rating"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/viewrate"
android:layout_weight="0.00"
android:onClick="display"/>
<ScrollView
android:id="@+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/button2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:textStyle="bold" />
<RatingBar
android:id="@+id/rat"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:isIndicator="false"
android:layout_weight="0.07" />
/>
</LinearLayout>
</ScrollView>
</LinearLayout>
可以使用'RatingBar'爲。 –