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环形进度条(安卓默认形式)的相关知识,希望对大家有所帮助!