ANDROID_MARS学习笔记_S01_012_RatingBar
1.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" > <RatingBar
android:id="@+id/firstRatingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="4"
android:stepSize="1"
/> <Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/firstRatingBar"
android:text="button"/> </RelativeLayout>
2.java
package com.marschen.s01e_e18_ratingbar; import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.RatingBar;
import android.widget.RatingBar.OnRatingBarChangeListener; public class MainActivity extends Activity { private RatingBar ratingBar;
private Button button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main); ratingBar = (RatingBar)findViewById(R.id.firstRatingBar);
button = (Button)findViewById(R.id.button); RatingBarListener listener = new RatingBarListener();
ratingBar.setOnRatingBarChangeListener(listener); ButtonListener buttonListener = new ButtonListener();
button.setOnClickListener(buttonListener);
} class ButtonListener implements OnClickListener{ @Override
public void onClick(View v) {
ratingBar.setRating(ratingBar.getRating() + 1.0f);
} } class RatingBarListener implements OnRatingBarChangeListener{ @Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
System.out.println("rating:" + rating + ",fromUser:" + fromUser);
} }
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
} }
ANDROID_MARS学习笔记_S01_012_RatingBar的更多相关文章
- ANDROID_MARS学习笔记_S01_012_SeekBar
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_011ProgressBar
文档是这样来设置样式 <ProgressBar android:layout_width="wrap_content" android:layout_height=" ...
- ANDROID_MARS学习笔记_S01_010日期时间控件
1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...
- ANDROID_MARS学习笔记_S01_009Relative_LAYOUT例子
1. <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android ...
- ANDROID_MARS学习笔记_S01_008Linear_layout例子
1.netstone_layout.xml <?xml version="1.0" encoding="utf-8"?> <LinearLay ...
- ANDROID_MARS学习笔记_S01_007Linear_layout嵌套与layout_weight的设置
一.介绍 二.1.linear_layout.xml <?xml version="1.0" encoding="utf-8"?> <Line ...
- ANDROID_MARS学习笔记_S01_006ImageView
一.ImageView介绍 设置scalType Must be one of the following constant values. Constant Value Description ma ...
- ANDROID_MARS学习笔记_S01_005CheckBox
一. 1.checkbox_layout.xml <?xml version="1.0" encoding="utf-8"?> <Linear ...
- ANDROID_MARS学习笔记_S01_004dpi、dp(dip)及计算
一.dpi.dp介绍 sp会随着用户在手机中设置字体大小而改变,而dp不会 二.1.dpsp_layout.xml <?xml version="1.0" encoding= ...
随机推荐
- 【leetcode】363. Max Sum of Rectangle No Larger Than K
题目描述: Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the ma ...
- poj 1286 Necklace of Beads
这是做的第一道群论题,自然要很水又很裸.注意用long long. 就是用到了两个定理 burnside :不等价方案数=每个置换的不动置换方案数的和 / 置换个数 polya: 一个置换的不动置换方 ...
- MDM基于IOS设备管控功能的所有命令介绍
前面我们介绍了IOS上MDM几个简单的控制命令的发送和返回数据的解析处理,下面我们介绍一下MDM涉及到的命令的操作介绍: 一.Control Commands(控制类命令) 1.Device Lock ...
- 6款好用的Python IDE
“工欲善其事,必先利其器”,如果说编程是程序员的手艺,那么IDE就是程序员吃饭的家伙了.一个优秀的IDE,最重要的就是在普通文本编辑之外,提供针对特定语言的各种快捷编辑功能,让程序员尽可能快捷.舒适. ...
- btrace 实践笔记
btrace简介: btrace 是一个使用在JAVA平台上面的,安全的,动态跟踪工具.它一般用于动态跟踪正在运行的jAVA程序. 使用说明在这里.下载地址在这里. 下载的时候 ...
- shell curl
最近突然发现了一个有趣的问题:怎样判断日期是工作日还是节假日.(http://www.cnblogs.com/ZXdeveloper/p/4018886.html) 顺便发现了一个有用的网址:http ...
- Nginx配置文件变量大全
$args # 这个变量等于请求行中的参数. $binary_remote_addr # 远程地址的二进制表示 $body_bytes_sent # 已发送的消息体字节数 $content_lengt ...
- iOS 开发一年总结
收获很多 1. 一个人包办从构思, 设计, 实现, 推广的全过程, 对自己的能力, 特别是能力范围有很大的提升. 以前在公司上班仅仅局限在实现的局域内, 现在在做自己的产品时, 在设计时的取舍, 对工 ...
- easy ui easyui-linkbutton 禁用、启用
<a id="btn_update_Shop" name="btn_update_Shop" class="easyui-linkbutton& ...
- 演示demo开发问题及解决方案集锦
模型处理问题: 1. 3Dmax模型导入Unity单位设置: 自定义->单位设置->系统单位设置与显示单位比例都调成厘米 2. 3Dmax中材质贴图: 点击材质编辑器[在模式下可以选择精简 ...