zoukankan      html  css  js  c++  java
  • RatingBar

    一、RatingBar

    Activity代码

    public class RatingBarDemoActivity extends Activity {

        private RatingBar rb=null;

        /** Called when the activity is first created. */

        @Override

        public void onCreate(Bundle savedInstanceState) {

            super.onCreate(savedInstanceState);

            setContentView(R.layout.main);

            rb=(RatingBar)findViewById(R.id.ratingbar1);

            rb.setOnRatingBarChangeListener(new ClickRatingBar());

    }

    //设置监听器

        class ClickRatingBar implements RatingBar.OnRatingBarChangeListener{

           @Override

           public void onRatingChanged(RatingBar ratingBar, float rating,

                  boolean fromUser) {

               // TODO Auto-generated method stub

               Toast.makeText(RatingBarDemoActivity.this, rating+"", Toast.LENGTH_LONG).show();

               

           }

        

        }

    }

    Main.xml代码:

    <?xmlversion="1.0"encoding="utf-8"?>

    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"

        android:orientation="vertical"

        android:layout_width="fill_parent"

        android:layout_height="fill_parent"

        >

    <TextView  

        android:layout_width="fill_parent" 

        android:layout_height="wrap_content" 

        android:text="@string/hello"

        />

    <RatingBar 

        android:id="@+id/ratingbar1"

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content"

        android:numStars="5"

        android:stepSize="0.5"

        />

    </LinearLayout>

  • 相关阅读:
    求最大子数组和
    第四周学习进度
    四则运算3
    实用工具箱app开发日记5
    实用工具箱app开发日记4
    实用工具箱app开发日记3
    实用工具箱app开发日记2
    实用工具箱app开发日记1
    《软件需求与分析》阅读笔记
    软件需求分析--阅读笔记3
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429513.html
Copyright © 2011-2022 走看看