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);
}
}
}); } }


												

Android常见控件— — —ProgressBar的更多相关文章

  1. Android基础控件ProgressBar进度条的使用

    1.简介 ProgressBar继承与View类,直接子类有AbsSeekBar和ContentLoadingProgressBar, 其中AbsSeekBar的子类有SeekBar和RatingBa ...

  2. Android -- 常见控件的小效果

    1,EditText控件 ① 修改光标颜色 自定义drawable 创建cursor.xml文件 <?xml version="1.0" encoding="utf ...

  3. Android --> 常见控件

    1.TextView  主要用于界面上显示一段文本信息 2.Button  用于和用户交互的一个按钮控件 //为Button点击事件注册一个监听器public class Click extends ...

  4. Android常见控件— — —ProgressDialog

    package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...

  5. Android常见控件— — —AlertDialog

    package com.example.uiwidgettest2; import android.app.Activity;import android.app.AlertDialog;import ...

  6. Android:控件ProgressBar进度条

    各种进度条属于 ProgressBar的子类 设置style: 环形进度条   style="?android:attr/progressBarStyleLarge" 横向进度条, ...

  7. Android常见控件— — —EditText

    <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android=" ...

  8. Android常见控件— — —Button

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...

  9. Android常见控件— — —TextView

    <?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android=&qu ...

随机推荐

  1. Dynamics AX 2012 R2 配置报表服务器

    今天Reinhard在使用报表的过程中,发现以下错误: The default Report Server Configuration ID could not be found in the SRS ...

  2. 打包app命令行

    $ cd myApp $ ionic platform add android $ ionic build android $ ionic emulate android

  3. 用andtoid studio获取天气数据并解析适配

    1.申请拿到数据 可以用“聚合数据” 2.在android studio中导入需要的jar包 复制—>app—>libs—>粘贴—>右击—>Add As Library… ...

  4. ubuntu下gcc、g++和gfortran版本切换

    第一步:用 which gcc.which g++和which gfortran查看位置,我的显示结果为:/usr/bin/gcc:/usr/bin/g++和/usr/bin/gfortran 第二部 ...

  5. c++链表归并排序的迭代版本

    之前用js写了个归并排序非递归版,而这一次,c++封装链表的时候也遇到了一个归并排序的接口.邓老师实现了递归版本的归并排序,但是递归的调用函数栈的累积是很占内存空间的.于是乎,那试试在链表结构上实现以 ...

  6. 异常问题解决Error:Execution failed for task ':app:processDebugManifest'

    Error:Execution failed for task ':app:processDebugManifest' www.MyException.Cn  网友分享于:2015-12-28  浏览 ...

  7. EFS加密解密----重装系统后

    重装系统尤其是格式化重装系统之后,如果没有正确地备份私钥,那么加密的文件将无法打开,加密的文件也暂时没有办法进行快速破解. 并非重装后用相同用户名+密码就可以解密的. Advanced EFS Dat ...

  8. C++实现树的基本操作,界面友好,操作方便,运行流畅,运用模板

    Ⅰ.说明: .采用左孩子右兄弟的方式,转化为二叉树来实现. .树的后根遍历与二叉树的中根遍历即有联系又有区别,请读者注意分析体会. Ⅱ.功能: .创建树并写入数据 .先根遍历树 .计算树高 .后根遍历 ...

  9. iOS - C 基本语法

    1.数据类型 2.常量 1)凡是整数数字常量一律是 int 型. 2)typedef 和 define. typedef 定义类型, #define 只是字符串替换. 3)在编写整形常量时,可以在常量 ...

  10. ural1057 Amount of Degrees

    链接 这题有一点小坑点 就是AX^B  A只能为0或者1  ,剩下的就比较好做的了. #include <iostream> #include<cstdio> #include ...