¾îÇø®ÄÉÀ̼ÇÀÌ µ¿ÀÛÇÏ´Â µµÁß¿¡ ±ä ½Ã°£ÀÇ I/O ÀÛ¾÷À̶ó´øÁö »ç¿ëÀڷκÎÅÍ È®ÀÎ ¸í·ÉÀ» ¹Þ¾Æ¾ß ÇÒ¶§¿Í °°Àº °æ¿ì
ÇöÀç ¿¢Æ¼ºñƼ »ó¿¡ »õ·Î¿î ´ÙÀ̾ó·Î±×¸¦ Ç¥½ÃÇÒ ÇÊ¿ä°¡ ÀÖ´Ù.
ProgressDialog´Â I/O ÀÛ¾÷°ú °°ÀÌ Àá½Ã ¿¢Æ¼ºñÀÌÀÇ »óŸ¦ µ¿°á½Ãų ¶§ »ç¿ëµÇ°í, AlertDialog´Â »ç¿ëÀڷκÎÅÍ È®ÀÎ ¸í·ÉÀ» ¹ÞÀ» ¶§ »ç¿ëµÈ´Ù.
public class MainActivity extends Activity {
ProgressDialog progressDialog; // ProgressDialog
Button btShowDialog;
Button btAlert;
public static int TIME_OUT = 1001;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btShowDialog = (Button) findViewById(R.id.btShowDialog);
btAlert = (Button) findViewById(R.id.btShowAlert);
alertDialog = new AlertDialog.Builder(this);
}
public void onClick(View v) {
// ShowDialog ¹öÆ°ÀÏ Å¬¸¯µÉ ¶§ È£Ãâ
if (v.getId() == btShowDialog.getId()) {
// ProgressDialog »ý¼º
progressDialog = ProgressDialog.show(this, "Title", "Message");
// Á¤ÇØÁø ½Ã°£ ÈÄ¿¡´Â ŸÀӾƿô ¹ß»ýÀ» À§ÇØ Çڵ鷯·Î ¸Þ½ÃÁö Àü´Þ
mHandler.sendEmptyMessageDelayed(TIME_OUT, 2000);
}
}
Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
if (msg.what == TIME_OUT) { // ŸÀӾƿôÀÌ ¹ß»ýÇϸé
progressDialog.dismiss(); // ProgressDialog¸¦ Á¾·á
}
}
};
}
ProgressDialog »ç¿ë¹ý
ProgressDialogÀÇ »ý¼º ¹× Ç¥½Ã´Â Àº ¶óÀÎ 27¹ø°ú °°ÀÌ Ã³¸®ÇÑ´Ù. ¶ÇÇÑ Ç¥½ÃµÈ ProgressDialog°¡ »ç¶óÁú ¼ö ÀÖµµ·Ï Çڵ鷯·Î Áö¿¬µÈ ¸Þ½ÃÁö¸¦ ´øÁø´Ù(¶óÀÎ 30).
Çڵ鷯´Â Áö¿¬µÈ ¸Þ½ÃÁö¸¦ ¹Þ¾Æ¼ ¶óÀÎ 63,64ó·³ Æ˾÷µÇ¾î ÀÖ´Â ProgressDialog¸¦ »èÁ¦ÇÑ´Ù.