<?xml version="1.0" encoding="utf-8"?>

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"> <RatingBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ratingbar" /> </LinearLayout>
package com.example.yanlei.my;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.RatingBar;
import android.widget.Toast; public class MainActivity extends AppCompatActivity { //声明变量
//声明RatingBar
private RatingBar rbScore=null;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); //获取RatingBar
rbScore = (RatingBar)findViewById(R.id.ratingbar); //设置监听事件
rbScore.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener(){
public void onRatingChanged(RatingBar ratingBar, float rating,boolean fromUser) {
Toast.makeText(getApplication(), "rating:"+String.valueOf(rating),Toast.LENGTH_SHORT).show();
}
});
} @Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
} @Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId(); //noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
} return super.onOptionsItemSelected(item);
}
}

参看:http://blog.csdn.net/jianghuiquan/article/details/8350476

评分条RatingBar Android的更多相关文章

  1. android 评分条 RatingBar 使用及自定义

    一.先上效果图片: 第一个是自定义: 第二个是原生的: 二.atingBar 介绍: RatingBar是基于SeekBar和ProgressBar的扩展,用星型来显示等级评定.使用RatingBar ...

  2. 7.Android之评分条RatingBar和拖动条SeekBar学习

    评分条RatingBar和拖动条SeekBar很常见,今天来学习下. (1)RatingBar评分条 如图: <RelativeLayout xmlns:android="http:/ ...

  3. Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar

    原文:Android零基础入门第53节:拖动条SeekBar和星级评分条RatingBar 前面两期都在学习ProgressBar的使用,关于自定义ProgressBar的内容后期会继续学习的,本期先 ...

  4. Android 自学之星级评分条RatingBar

    星级评分条(RatingBar)与拖动条十分相似,他们还有共同的父类AbsSeekBar.实际上星级评分条和拖动条的用法和功能都十分的接近:他们都允许用户通过拖动来改变进度.RatingBar与See ...

  5. 更改星级评分条 RatingBar 的样式

    1.首先在布局中引用星级评分条: <RatingBar            android:id="@+id/room_ratingbar"            styl ...

  6. ProgressBar(进度条)、SeekBar(拖动条)与星级评分条(RatingBar)

    1.ProgressBar(进度条) (1)介绍 (2)常用属性 (3)xml代码 <ProgressBar android:id="@+id/progressBar2" s ...

  7. android评分条RatingBar自定义设置

    RatingBar为评分条控件,默认效果为若干个绿色的星星,如果想将其换成其他自定义图片就要自定义它的style.首先是布局文件: 其中android:numStars="5"设置 ...

  8. 星级评分条(RatingBar)的功能和用法

    星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星级评分条与拖动条的用法.功能都十分接近:它们都是允许用户通过拖动条来改变进度.RatingBar与SeekBar最大区别 ...

  9. 星级评分条(RatingBar)的功能与用法

    星级评分条与拖动条有相同的父类:AbsSeekBar,因此它们十分相似.实际上星际评分条与拖动条的用法.功能都十分接近:它们都允许用户通过拖动来改变进度.RatingBar与SeekBar的最大区别在 ...

随机推荐

  1. HTML5/CSS3速成教程

    http://www.w3cfuns.com/thread-5592317-1-1.html

  2. Github问题An error occurred trying to download

    Github for windows安装过程出现了这样的问题An error occurred trying to download 'http://github-windows.s3.amazona ...

  3. day05_07 标志位讲解

    continue: 需求:大于5才打印 for i in range(10): if i<6 : continue print(i) continue作用:结束本次循环,继续下次循环 break ...

  4. 【译】从现有的容器里创建新的Docker镜像

    如果你修改了一个容器的内容,你可以使用docker commit命令将现有的容器状态保存为一个镜像. 下面的例子展示了如何修改一个基于oraclelinux:6.6的容器使得其能够运行Apache H ...

  5. zookeeper 集群

    集群步骤: 1.安装zookeeper 2.修改zookeeper配置文件 3.创建myid文件 安装zookeeper:查看安装步骤 修改zookeeper配置文件:在zoo.cfg中添加配置 se ...

  6. 【转】Unity3D研究院之DontDestroyOnLoad的坑

    http://www.xuanyusong.com/archives/2938 Unity中的一个方法DontDestroyOnLoad可以让某些游戏对象在切换场景的时候不是施放,听起来是一个非常好的 ...

  7. 手机安装app总是显示未安装

    手机安装软件总是显示未安装 查看是否开启了护眼模式或者护眼工具等干扰屏幕的软件.关掉,再安装即可

  8. 【15】vuex2.0 之 modules

    vue 使用的是单一状态树对整个应用的状态进行管理,也就是说,应用中的所有状态都放到store中,如果是一个大型应用,状态非常多, store 就会非常庞大,不太好管理.这时vuex 提供了另外一种方 ...

  9. Mysql和sqlServer命令比较

    http://cool.china.blog.163.com/blog/static/697310642010111202531210 Mysql和sqlServer命令比较 按语句功能划分,依次讲解 ...

  10. HDOJ 1171 Big Event in HDU

    Big Event in HDU Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others ...