服务器之家:专注于服务器技术及软件下载分享
分类导航

PHP教程|ASP.NET教程|Java教程|ASP教程|编程技术|正则表达式|C/C++|IOS|C#|Swift|Android|VB|R语言|JavaScript|易语言|vb.net|

服务器之家 - 编程语言 - Android - Android环形进度条(安卓默认形式)实例代码

Android环形进度条(安卓默认形式)实例代码

2021-06-22 14:17baohanqing Android

这篇文章主要介绍了Android环形进度条(安卓默认形式)实例代码的相关资料,需要的朋友可以参考下

android开发中,有很多的功能在实际应用中都起了很大的作用,比如android进度条的实现方式,下面给大家介绍android环形进度条(安卓默认形式),具体内容如下所示:

.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
<linearlayout 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:orientation="vertical"
tools:context=".mainactivity" >
<button
android:id="@+id/mybut"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="查找网络"/>
</linearlayout>

.java

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.example.progressdialog;
import android.os.bundle;
import android.app.activity;
import android.app.progressdialog;
import android.view.view;
import android.view.view.onclicklistener;
import android.widget.button;
public class mainactivity extends activity {
private button but=null;
@override
protected void oncreate(bundle savedinstancestate) {
super.oncreate(savedinstancestate);
setcontentview(r.layout.activity_main);
this.but=(button) super.findviewbyid(r.id.mybut);
this.but.setonclicklistener(new onclicklistenerimp());
}
public class onclicklistenerimp implements onclicklistener{
public void onclick(view v) {
//创建我们的进度条
final progressdialog prodia=new progressdialog(mainactivity.this);
prodia.settitle("搜索网络");
prodia.setmessage("请耐心等待");
prodia.onstart();
//匿名内部类
new thread(){
public void run(){
try{
thread.sleep(3000);
}
catch(exception e){
}
finally{
//匿名内部类要访问类当中的数据,该数据必须为final
prodia.dismiss();//隐藏对话框
}
}
}.start();
prodia.show();
}
}
}

以上内容是小编给大家介绍的android环形进度条(安卓默认形式)的相关知识,希望对大家有所帮助!

延伸 · 阅读

精彩推荐