Android RatingBar usage

Source: Internet
Author: 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>
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.