Android環(huán)形進度條(安卓默認形式)實例代碼
更新時間:2016年03月01日 11:37:16 作者:baohanqing
這篇文章主要介紹了Android環(huán)形進度條(安卓默認形式)實例代碼的相關資料,需要的朋友可以參考下
Android開發(fā)中,有很多的功能在實際應用中都起了很大的作用,比如android進度條的實現(xiàn)方式,下面給大家介紹Android環(huán)形進度條(安卓默認形式),具體內容如下所示:
.xml
<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="查找網(wǎng)絡"/> </LinearLayout>
.java
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) {
//創(chuàng)建我們的進度條
final ProgressDialog proDia=new ProgressDialog(MainActivity.this);
proDia.setTitle("搜索網(wǎng)絡");
proDia.setMessage("請耐心等待");
proDia.onStart();
//匿名內部類
new Thread(){
public void run(){
try{
Thread.sleep(3000);
}
catch(Exception e){
}
finally{
//匿名內部類要訪問類當中的數(shù)據(jù),該數(shù)據(jù)必須為final
proDia.dismiss();//隱藏對話框
}
}
}.start();
proDia.show();
}
}
}
以上內容是小編給大家介紹的Android環(huán)形進度條(安卓默認形式)的相關知識,希望對大家有所幫助!
相關文章
Android仿騰訊QQ實現(xiàn)滑動刪除 附源碼下載
仿騰訊QQ滑動刪除操作,這篇文章主要為大家詳細介紹了ListView滑動刪除的具體操作方法,感興趣的小伙伴們可以參考一下2016-07-07
FlowLayout流式布局實現(xiàn)搜索清空歷史記錄
這篇文章主要為大家詳細介紹了FlowLayout流式布局實現(xiàn)搜索清空歷史記錄,具有一定的參考價值,感興趣的小伙伴們可以參考一下2018-12-12
Android Studio 4.0 正式發(fā)布在Ubuntu 20.04中安裝的方法
這篇文章主要介紹了Android Studio 4.0 正式發(fā)布如何在Ubuntu 20.04中安裝,本文給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-06-06
android studio無法添加 bmob sdk依賴問題及解決方法
這篇文章主要介紹了android studio無法添加 bmob sdk依賴,本文通過圖文并茂的形式給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-05-05

