activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E6E6E6"
android:orientation="vertical">
<ImageViewandroid:id="@+id/iv"android:layout_width="70dp"android:layout_height="70dp"android:layout_centerHorizontal="true"android:layout_marginTop="40dp"android:background="@drawable/head"/>
<LinearLayoutandroid:id="@+id/ll_number"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/iv"android:layout_centerVertical="true"android:layout_marginBottom="5dp"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginTop="15dp"android:background="#ffffff"><TextViewandroid:id="@+id/tv_number"android:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="10dp"android:text="账号:"android:textColor="#000"android:textSize="20sp"/><EditTextandroid:id="@+id/et_number"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:background="@null"android:padding="10dp"/>
</LinearLayout>
<LinearLayoutandroid:id="@+id/ll_password"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/ll_number"android:layout_centerVertical="true"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:background="#ffffff"><TextViewandroid:id="@+id/tv_password"android:layout_width="wrap_content"android:layout_height="wrap_content"android:padding="10dp"android:text="密码:"android:textColor="#000"android:textSize="20sp"/><EditTextandroid:id="@+id/et_number2"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginLeft="5dp"android:background="@null"android:padding="10dp"/>
</LinearLayout>
<Buttonandroid:id="@+id/btn_login"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_below="@id/ll_password"android:layout_marginLeft="10dp"android:layout_marginRight="10dp"android:layout_marginTop="50dp"android:background="#3C8DC4"android:text="登录"android:textColor="#ffffff"android:textSize="20sp"/></RelativeLayout>

MainActivity.java:

package com.example.lenovo.myapplicationloading;import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;public class MainActivity extends AppCompatActivity {private Button xhButton01, xhButton02;int xh_count = 0;// 声明进度条对话框ProgressDialog xh_pDialog;@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);// 得到按钮对象xhButton02 = (Button) findViewById(R.id.btn_login);// 设置xhButton02的事件监听xhButton02.setOnClickListener(new Button.OnClickListener() {@Overridepublic void onClick(View v) {xh_count = 0;// 创建ProgressDialog对象xh_pDialog = new ProgressDialog(MainActivity.this);// 设置进度条风格,风格为圆形,旋转的xh_pDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);// 设置ProgressDialog 标题xh_pDialog.setTitle("提示");// 设置ProgressDialog提示信息xh_pDialog.setMessage("正在加载中……");// 设置ProgressDialog标题图标xh_pDialog.setIcon(R.drawable.shape_progressbar_bg);// 设置ProgressDialog 的进度条是否不明确 false 就是不设置为不明确xh_pDialog.setIndeterminate(false);// 设置ProgressDialog 进度条进度xh_pDialog.setProgress(100);// 设置ProgressDialog 是否可以按退回键取消xh_pDialog.setCancelable(true);// 让ProgressDialog显示xh_pDialog.show();new Thread() {@Overridepublic void run() {try {while (xh_count <= 100) {// 由线程来控制进度xh_pDialog.setProgress(xh_count++);Thread.sleep(100);}xh_pDialog.cancel();} catch (Exception e) {xh_pDialog.cancel();}}}.start();}});}// xhButton01的监听器类class Bt1DialogListener implements DialogInterface.OnClickListener {@Overridepublic void onClick(DialogInterface dialog, int which) {// 点击“确定”按钮取消对话框dialog.cancel();}}
}

运行结果:

Android:进度条加载相关推荐

  1. 基于腾讯 x5 开源库,提高 webView 开发效率,大概要节约你百分之六十的时间成本。该案例支持处理 js 的交互逻辑且无耦合、同时暴露进度条加载进度、可以监听异常 error 状态、支持视频播放

    YCWebView 项目地址:yangchong211/YCWebView 简介: 基于腾讯 x5 开源库,提高 webView 开发效率,大概要节约你百分之六十的时间成本.该案例支持处理 js 的交 ...

  2. html动态资源加载进度,JavaScript_快速解决js动态改变dom元素属性后页面及时渲染的问题,今天实现一个进度条加载过程 - phpStudy...

    快速解决js动态改变dom元素属性后页面及时渲染的问题 今天实现一个进度条加载过程,dom结构其实就是两个div 控制里层div的宽width属性,就能实现进度条往前走的效果. 我的进度条是显示下载文 ...

  3. 超酷jQuery进度条加载动画集合

    在丰富多彩的网页世界中,进度条加载动画的形式非常多样,有利用gif图片实现的loading动画,也有利用jQuery和CSS3实现的进度加载动画,本文主要向大家介绍很多jQuery和CSS3实现的进度 ...

  4. Unity实现扇形Slider进度条加载功能

    Unity实现扇形Slider进度条加载功能 前言 在实际的开发项目中,再跳转场景的时候可以加一个进度条显示的功能,这样在跳转场景的时候就不会显得很突兀.在进度条的实现方式中,有很多的方式,例如Uni ...

  5. unity进度条加载

    首先创建一个unity自带的UI--Slider,并在其下面再添加一个Text 在其下面添加脚本 using System.Collections; using System.Collections. ...

  6. vbs如何写进度条_VBS 调用 HTA 实现进度条加载

    因为工作需要前几天做了个导表脚本 XLS2TXT 但是当表很多时有个纠结的问题,不显示EXCEL会让人不知道进展,还以为卡死了. 显示excel 不停的刷表格,很不美观. 我是无法接受这种情况的,所以 ...

  7. Unity制作圆环进度条加载场景资源

    第一步:场景内UI圆环的搭建 新建一张Panel作为背景图,在Panel下新建一张Image命名为RoundImage作为外圆环,在外圆环下新建一张image命名为RoundLoading作为内圆环, ...

  8. Java Swing 实现loading进度条加载效果

    前言必读 ​​​​​​​读者手册(必读)_云边的快乐猫的博客-CSDN博客 前言: 这个可以用来做一些页面的加载进度条还是很不错的,起到美观的作用,一些代码内容也是根据别的大佬拿来修改完成.这是在id ...

  9. php 载入css就可以显示,如何在进度条加载后显示页面

    1.思路:加入很多图片,以延迟加载时间,实现加载完后显示图片.定义一个外层p,覆盖住图片,在内层p中引入加载时显示的图片,让内层p居中在页面上,利用setInterval定时器设置3秒后将外层p隐藏, ...

最新文章

  1. 难点电路详解之负反馈放大器电路(3)
  2. Unity之Update与FixedUpdate区别
  3. Linux_Centos中搭建nexus私服
  4. hadoop-1.1.2 在centos环境下的部署
  5. 从《王者荣耀》来聊聊游戏的帧同步
  6. Arm 64位 汇编入栈和出栈
  7. B00004 atoi函数
  8. mysql5.7.11解压安装_mysql 5.7.11解压安装教程
  9. MongoDB实战经验分享
  10. 基于jQuery UI CSS Framework开发Widget
  11. 计算机学院特色迎新标语,开学迎新口号
  12. matlab flightgear,matlab与flightGear联合仿真
  13. TongWeb8知识总结
  14. 【C++ 程序】 小游戏汇编
  15. 前端开发者必会的英语单词
  16. 2014年数学建模美赛题目原文及翻译[个人思路]
  17. android studio 官方虚拟机,Android Studio 移动虚拟机
  18. 获取华为手机的IMEI和sn号
  19. 丢番图生平编程java_丢番图
  20. 2023年核桃仁行业产业布局:全球核桃仁产量稳步增长

热门文章

  1. Jsp页面的几种传参方式
  2. python getostime_python转换在os.utime中使用的datetime
  3. android 多进程 坑,Android 开发中踩过的坑之八:多进程问题
  4. c# mysql 链接池溢出_C#MySQL连接池限制,并清理连接
  5. 二叉树前序遍历_LeetCode125|二叉树的前序遍历
  6. 把网站图片和php程序分离,我的图片服务器和WEB应用服务器相分离的简单方案
  7. 顺网无盘服务器木马,无盘顺网虚拟服务器设置
  8. 跟熊浩学沟通30讲读后感_怎样提高自己的沟通表达能力
  9. 负责指挥与控制整台电子计算机,2011秋季计算机应用基础期末考试卷(修改)
  10. js byte数组转string_JVM系列之:String,数组和集合类的内存占用大小