ProgressBar用于在界面上显示一个进度条,表示我们的程序正在加载一些数据。


<?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"> <ProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"/> <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="progress消失"/> <Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="progress重现"/> </LinearLayout>

package com.example.uiwidgettest2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*; public class edittextActivity extends Activity{ private ProgressBar progressBar = null;
private Button btn1 = null;
private Button btn2 = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edittext); progressBar = (ProgressBar)findViewById(R.id.progress_bar);
btn1 = (Button)findViewById(R.id.button1);
btn2 = (Button)findViewById(R.id.button2); btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(progressBar.getVisibility() == View.VISIBLE){
progressBar.setVisibility(View.GONE);
}
}
}); btn2.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if(progressBar.getVisibility() == View.GONE){
progressBar.setVisibility(v.VISIBLE);
}
}
});
} }


<?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"> <ProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
/> <Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="progress"/> </LinearLayout>

package com.example.uiwidgettest2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.*; public class edittextActivity extends Activity{ private ProgressBar progressBar = null;
private Button btn1 = null; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.edittext); progressBar = (ProgressBar)findViewById(R.id.progress_bar);
btn1 = (Button)findViewById(R.id.button1); btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int progress = progressBar.getProgress();
progress = progress+10;
if(progressBar.getProgress() <= 100){
progressBar.setProgress(progress);
}
}
}); } }


												

最新文章

  1. iOS NSNotificationCenter详解
  2. Intellij IDEA工具Java web 环境搭建
  3. EasyUI中datagrid控件的使用 设置多行表头(两行或多行)
  4. (译)利用ASP.NET加密和解密Web.config中连接字符串
  5. 隐知识:reloadData 方法之后,view并不会立即更新其contentSize
  6. iOS学习笔记---简单的学习总结
  7. ios学习笔记第三天之UI控件
  8. Git分支-分支简介
  9. Java 前端模板引擎学习:thymeleaf 模板引擎
  10. 记录一次.Net框架Bug发现和提交过程:.Net Framework和.Net Core均受影响
  11. Django + Mysql 中关于时间异常返回500错误的解决
  12. &lt;构建之法&gt;10,11,12章的读后感
  13. 第一阶段——站立会议总结DAY01
  14. MongoDB给数据库创建用户
  15. 前端弹窗展示后台html文件
  16. webkit开源项目
  17. 第十周课下作业-IPC
  18. Working C# code for MySql5.5 Stored Procedures IN parameters
  19. 源码分析:动态分析 Linux 内核函数调用关系
  20. Hibernate 一对一映射(惟一外键)

热门文章

  1. 33、mybatis(二)
  2. StringBuilder和Append的一个程序及一个基础概念
  3. Android-Universal-Image-Loader的缓存处理机制
  4. radius服务器搭建
  5. Java 中的 static 使用之静态初始化块
  6. js获取url中的参数值
  7. 里面的div怎么撑开外面的div让高度自适应
  8. 《BI项目笔记》创建父子维度
  9. HTML的基本认识
  10. HBase之集群状态