공부중에 인터넷에서 본 소스인데,
	빌드해보니 첫 실행은 정상적으로 되나, 두번째부터는 100%로 프로그래스가 맞춰진 상태로 사라지질 않네요.
	어떤 부분이 문제일까요.
	 
	버튼을 하나 배치하여 버튼을 누르면 프로그래스 다이얼로그가 뜨도록 되어 있습니다.
	처음 버튼을 눌렀을 때는 정상적으로 작동하나,
	프로그래스가 100% 완료된 후 다이얼로그가 사라진 상태에서,
	다시 버튼을 눌러 프로그래스를 실행했을 때는 프로그래스바가 100%에 맞춰진 상태로 사라지질 않습니다.
	 
	 
package com.example.longtimetest;
import android.app.Activity;
import android.app.Dialog;
import android.app.ProgressDialog;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity{
	static final int PROGRESS_DIALOG = 0;
	Button button;
	ProgressThread progressThread;
	ProgressDialog progressDialog;
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		button = (Button) findViewById(R.id.button1);
		//button.setOnClickListener(mOnClick);
		
		
		
		button.setOnClickListener(new OnClickListener() {
			public void onClick(View v) {
				showDialog(327);
			}
		});
	}
	
	protected Dialog onCreateDialog(int id) {
		switch (id) {
		case 327:
			progressDialog = new ProgressDialog(MainActivity.this);
			progressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
			progressDialog.setCancelable(false);
			progressDialog.setTitle("Titlebar");
			progressDialog.setMessage("Loading...");
			progressThread = new ProgressThread(handler);
			progressThread.start();
			return progressDialog;
		default:
			return null;
		}
	}
	// 핸들러는 정의하여 스레드가 메시지를 보내면 프로그레스를 업데이트 합니다.
	final Handler handler = new Handler() {
		public void handleMessage(Message msg) {
			int total = msg.getData().getInt("total");
			progressDialog.setProgress(total);
			if (total >= 100) {
				dismissDialog(327);
				progressThread.setState(ProgressThread.STATE_DONE);
			}
		}
	};
	/** 프로그레스를 처리하는 클래스를 내부 클래스로 정의. */
	private class ProgressThread extends Thread {
		Handler mHandler;
		final static int STATE_DONE = 0;
		final static int STATE_RUNNING = 1;
		int mState;
		int total;
		ProgressThread(Handler h) {
			mHandler = h;
		}
		public void run() {
			mState = STATE_RUNNING;
			total = 0;
			while (mState == STATE_RUNNING) {
				try {
					Thread.sleep(100);
				} catch (InterruptedException e) {
					// 에러처리
				}
				Message msg = mHandler.obtainMessage();
				Bundle b = new Bundle();
				b.putInt("total", total);
				msg.setData(b);
				mHandler.sendMessage(msg);
				total++;
			}
		} 
		// 현재의 상태를 설정하는 메소드
		public void setState(int state) {
			mState = state;
		}
	}
}