• 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>

  • 相关阅读:
    Android之遍历SD卡所有文件显示在ListView
    Android之ViewPager
    控制ViewPager的切换速度
    Android中显示sd卡的图片和视频
    java中主线程等待所有子线程结束
    Android之ViewFlipper实现图片切换
    Android闹钟服务详解
    Gradle基本操作入手
    设计模式
    【CSON原创】 基于HTML5的小球物理测试系统
  • 原文地址:https://www.cnblogs.com/itfenqing/p/4429513.html
Copyright © 2020-2023  润新知