Android RatingBar 的用法

來源:互聯網
上載者:User

 1 package com.turbo;
2
3 import android.app.Activity;
4 import android.os.Bundle;
5 import android.widget.RatingBar;
6 import android.widget.Toast;
7
8 public class AndroidSeekBar extends Activity {
9 @Override
10 protected void onCreate(Bundle savedInstanceState) {
11 super.onCreate(savedInstanceState);
12 setContentView(R.layout.seek_bar);
13 final RatingBar ratingBar_Small = (RatingBar)findViewById(R.id.ratingbar_small);
14 final RatingBar ratingBar_Indicator = (RatingBar)findViewById(R.id.ratingbar_Indicator);
15 final RatingBar ratingBar_default = (RatingBar)findViewById(R.id.ratingbar_default);
16 ratingBar_default.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
17
18 @Override
19 public void onRatingChanged(RatingBar ratingBar, float rating,
20 boolean fromUser) {
21 ratingBar_Small.setRating(rating);
22 ratingBar_Indicator.setRating(rating);
23 Toast.makeText(AndroidSeekBar.this, "rating:" + String.valueOf(rating), Toast.LENGTH_LONG).show();
24 }
25 });
26 }
27
28 }

 

 1 <?xml version="1.0" encoding="utf-8"?>
2 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 android:layout_width="fill_parent"
4 android:layout_height="fill_parent"
5 android:orientation="vertical" >
6 <RatingBar
7 android:layout_width="wrap_content"
8 android:layout_height="wrap_content"
9 style="?android:attr/ratingBarStyleIndicator"
10 android:id="@+id/ratingbar_Indicator"
11 />
12 <RatingBar
13 android:layout_width="wrap_content"
14 android:layout_height="wrap_content"
15 style="?android:attr/ratingBarStyleSmall"
16 android:id="@+id/ratingbar_small"
17 android:numStars="20"
18 />
19 <RatingBar
20 android:layout_width="wrap_content"
21 android:layout_height="wrap_content"
22 style="?android:attr/ratingBarStyle"
23 android:id="@+id/ratingbar_default"
24 />
25 </LinearLayout>
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.