标签:android style blog http color io os 使用 java
1.效果图
2.代码
main.xml
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/LL" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <RatingBar android:id="@+id/ratingBar1" android:layout_width="wrap_content" android:layout_height="wrap_content" > </RatingBar> </LinearLayout>
firstActivity.java
final RatingBar mRating = (RatingBar) findViewById(R.id.ratingBar1); // 获取对象 mRating.setMax(100); // 设置最大值 mRating.setNumStars(5); // 设置星型数量 mRating.setStepSize((float) 0.5); // 设置步长 mRating.setRating((float) 3.5); mRating.setOnRatingBarChangeListener(new OnRatingBarChangeListener() { @Override public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) { // TODO Auto-generated method stub a = mRating.getRating();// 设置当前分数 Toast.makeText(firstActivity.this, "当前的分数为:" + a * 20, Toast.LENGTH_SHORT).show(); } });
标签:android style blog http color io os 使用 java
原文地址:http://www.cnblogs.com/SM-t/p/3981559.html