第3个回答 2014-01-11
简易代码//progress=ProgressDialog.show(SerachActivity.this,"搜索设备", "正在加载数据,请稍候...");Message msg = handler.obtainMessage();msg.what = 1;handler.sendMessageDelayed(msg, 延迟时间); private Handler handler = new Handler() { public void handleMessage(android.os.Message msg) { progress.dismiss();}}
第4个回答 2014-01-11
用AsyncTask,在启动AsyncTask时弹出一个对话框,然后doInBackground方法里做你想做的事情,事情做完了会自动执行onPostExecute方法,在这个方法里关闭对话框就行了private class getKeywordTask extends AsyncTask { @Override protected String doInBackground(String... params) { // TODO Auto-generated method stub /**做任何你想做的事情*/ return null; } @Override protected void onPostExecute(String result) { // TODO Auto-generated method stub mypDialog.dismiss(); //关闭对话框 } }