WEB开发网
开发学院手机开发Android 开发 Android 的 RatingBar 扩展 阅读

Android 的 RatingBar 扩展

 2010-03-25 16:59:00 来源:WEB开发网   
核心提示:android:layout_height="wrap_content" style="?android:attr/ratingBarStyle" android:id="@+id/ratingbar_default" /></LinearLayo
android:layout_height="wrap_content"

  style="?android:attr/ratingBarStyle"

  android:id="@+id/ratingbar_default"

  />

</LinearLayout>

AndroidRatingBar.java

package com.AndroidRatingBar;

import android.app.Activity;

import android.os.Bundle;

import android.widget.RatingBar;

import android.widget.Toast;

public class AndroidRatingBar extends Activity {

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

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

final RatingBar ratingBar_Small = (RatingBar)findViewById(R.id.ratingbar_Small);

final RatingBar ratingBar_Indicator = (RatingBar)findViewById(R.id.ratingbar_Indicator);

final RatingBar ratingBar_default = (RatingBar)findViewById(R.id.ratingbar_default);

ratingBar_default.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){

@Override

public void onRatingChanged(RatingBar ratingBar, float rating,

boolean fromUser) {

// TODO Auto-generated method stub

ratingBar_Small.setRating(rating);

ratingBar_Indicator.setRating(rating);

Toast.makeText(AndroidRatingBar.this, "rating:"+String.valueOf(rating),

Toast.LENGTH_LONG).show();

}});

}

}

上一页  1 2 3 4 

Tags:Android RatingBar 扩展

编辑录入:coldstar [复制链接] [打 印]
赞助商链接