从品牌网站建设到网络营销策划,从策略到执行的一站式服务
package com.example.testprogress; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.util.Log; import android.annotation.SuppressLint; import android.app.Activity; import android.app.ProgressDialog; @SuppressLint("HandlerLeak") public class MainActivity extends Activity { private ProgressDialog progressDialog = null; private boolean flag = true; private int count = 0; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); progressDialog = new ProgressDialog(this); progressDialog.setMessage("数据获取中..."); progressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER); progressDialog.setCancelable(false);//是否可以被返回键取消 progressDialog.show(); for(int i=0; i<100; i++){ new Thread(mRunnable).start(); } } private Runnable mRunnable = new Runnable(){ @Override public void run() { while(flag){ try { Thread.sleep(1000); count ++; mHandler.sendMessage(mHandler.obtainMessage()); } catch (InterruptedException e) { e.printStackTrace(); } } } }; private Handler mHandler = new Handler(){ public void handleMessage(Message msg){ Log.v("article", Thread.currentThread().getId()+""); if(count >= 4){ flag = false; progressDialog.dismiss(); } } }; }
成都网站建设公司地址:成都市青羊区太升南路288号锦天国际A座10层 建设咨询028-86922220
成都快上网科技有限公司-四川网站建设设计公司 | 蜀ICP备19037934号 Copyright 2020,ALL Rights Reserved cdkjz.cn | 成都网站建设 | © Copyright 2020版权所有.
专家团队为您提供成都网站建设,成都网站设计,成都品牌网站设计,成都营销型网站制作等服务,成都建网站就找快上网! | 成都网站建设哪家好? | 网站建设地图