ANDROID_MARS学习笔记_S01原始版_005_ProgressBar
一、代码
1.xml
(1)main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns: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"
/>
<ProgressBar
android:id="@+id/firstBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<ProgressBar
android:id="@+id/secondBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
/>
<Button
android:id="@+id/myButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="begin"
/>
</LinearLayout>
2.java
(1)ProgressBarTest.java
package mars.progressbar; import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ProgressBar; public class ProgressBarTest extends Activity {
/** Called when the activity is first created. */
//声明变量
private ProgressBar firstBar =null;
private ProgressBar secondBar = null;
private Button myButton = null;
private int i = 0 ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//根据控件的ID来取得代表控件的对象
firstBar = (ProgressBar)findViewById(R.id.firstBar);
secondBar = (ProgressBar)findViewById(R.id.secondBar);
myButton = (Button)findViewById(R.id.myButton);
myButton.setOnClickListener(new ButtonListener());
}
class ButtonListener implements OnClickListener{ @Override
public void onClick(View v) {
if(i == 0)
{
//设置进度条处于可见的状态
firstBar.setVisibility(View.VISIBLE);
firstBar.setMax(150);
secondBar.setVisibility(View.VISIBLE);
}
else if ( i < firstBar.getMax()){
//设置主进度条的当前值
firstBar.setProgress(i);
//设置第二进度条的当前值
firstBar.setSecondaryProgress(i + 10);
//因为默认的进度条无法显示进行的状态
//secondBar.setProgress(i); }
else{
//设置进度条处于不可见状态
firstBar.setVisibility(View.GONE);
secondBar.setVisibility(View.GONE);
}
i = i + 10 ;
} } }
ANDROID_MARS学习笔记_S01原始版_005_ProgressBar的更多相关文章
- ANDROID_MARS学习笔记_S01原始版_005_RadioGroup\CheckBox\Toast
一.代码 1.xml(1)radio.xml <?xml version="1.0" encoding="utf-8"?> <LinearLa ...
- ANDROID_MARS学习笔记_S01原始版_004_TableLayout
1.xml <?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android ...
- ANDROID_MARS学习笔记_S01原始版_003_对话框
1.AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest ...
- ANDROID_MARS学习笔记_S01原始版_002_实现计算乘积及menu应用
一.代码 1.xml(1)activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk ...
- ANDROID_MARS学习笔记_S01原始版_001_Intent
一.Intent简介 二.代码 1.activity_main.xml <RelativeLayout xmlns:android="http://schemas.android.co ...
- ANDROID_MARS学习笔记_S01原始版_023_MP3PLAYER005_用广播BroacastReciever实现后台播放不更新歌词
一.代码流程1.自定义一个AppConstant.LRC_MESSAGE_ACTION字符串表示广播"更新歌词" 2.在PlayerActivity的onResume()注册Bro ...
- ANDROID_MARS学习笔记_S01原始版_023_MP3PLAYER004_同步显示歌词
一.流程分析 1.点击播放按钮,会根据lrc名调用LrcProcessor的process()分析歌词文件,得到时间队列和歌词队列 2.new一个hander,把时间队列和歌词队列传给自定义的线程类U ...
- ANDROID_MARS学习笔记_S01原始版_023_MP3PLAYER003_播放mp3
一.简介 1.在onListItemClick中实现点击条目时,跳转到PlayerActivity,mp3info通过Intent传给PlayerActivity 2.PlayerActivity通过 ...
- ANDROID_MARS学习笔记_S01原始版_022_MP3PLAYER002_本地及remote标签
一.简介 1.在main.xml中用TabHost.TabWidget.FrameLayout标签作布局 2.在MainActivity中生成TabHost.TabSpec,调用setIndicato ...
随机推荐
- 简单测试IIS下的UrlRewrite技术
UrlRewrite即地址变换.它可以实现静态功能方便搜索引擎收录,比如http://***/news.asp?corangeid=11它可以变为htt://***/news-11.html.这样还实 ...
- ie编程半天的学习总结
自己好久没有来这个博客了,自己陆续去几个地方写博客,一个c++博客园,一个csdn. 感觉都一般吧,看不到什么好的博客,可能自己没有看到吧.以后就在这个博客记录一点技术笔记吧!自己比较懒,只要做为记录 ...
- ArryList vs LinkedList
references: http://www.javaperformancetuning.com/articles/randomaccess.shtml http://stackoverflow.co ...
- 公共语言运行库(CLR)和中间语言(IL)(一)
公共语言运行库(.net运行库)即CLR 1.C#先编译为IL,IL为ms的中间语言,IL是平台无关性的. 2.CLR再将IL编译为平台专用语言. 3.CLR在编译IL时为即时编译(JIT) VB.V ...
- angular2 select change 事件
刚开始这是啥?(wrong!!! change事件会在 选择option行为 之前执行prodDirId,是取不到选择后正确的id值的,取得是选择行为前prodDirId的值(有试过setTi ...
- 19_高级映射:一对多查询(使用resultMap)
[需求] 查询订单以及订单明细的信息. 确定主查询表:订单表orders 确定关联查询表:订单明细表 orderdetail 在一对一查询的基础上添加订单明细表关联即可. [分析] 使用resultM ...
- springmvc学习(二)——使用RequestMapper请求映射
本次内容是@RequestMapping,后面会有实例代码 Spring MVC 使用 @RequestMapping 注解为控制器指定可以处理哪些 URL 请求在控制器的类定义及方法定义处都可标注@ ...
- CUDA_矢量相加
#include<iostream> #define N 10 _ _global_ _ void add(*a,*b,*c) { int tid=blockIdx.x; if(tid&l ...
- bzoj1015:[JSOI2008]星球大战starwar
思路:反着做用并查集维护连通块个数就好了. #include<iostream> #include<cstdio> #include<cstring> #inclu ...
- C++ IO 详细用法
http://www.cnblogs.com/keam37/ keam所有 转载请注明出处 本文将分别从<iostream>,<sstream>,<fstream> ...