[英]Android RatingBar
我是android開發的新手
我需要創建一個RatingBar來根據“應用程序詳細信息”顯示評分。
我的應用程序根據用戶輸入計算一個值,該值將顯示在RatingBar中。
該條僅根據計算出的值顯示該值(例如4/5星)
我需要創建它以使用戶不能直接更改RatingBar的值。他們只能輸入輸入,而該輸入會計算一些值,並且該值需要顯示在RatingBar中。
你能幫我做到這一點嗎? 這是我無法想到的使用RatingBar的唯一方法(據我所知)。
試試看。我認為這可以解決您的問題
這是java代碼
RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar1);
ratingBar.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return true;
}
});
XML代碼
<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"
/>
如果需要限制用戶手動更改等級欄,則需要在等級欄實例上應用onTouchListener並返回true
嘗試isIndicator屬性。 如果設置為true,則用戶將無法通過觸摸RatingBar來更改值。
<RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.