티스토리 뷰

개발/개발 자료

[Android] Progress Bar

시원한물냉 2013. 10. 1. 10:55

- 사용자로부터 기다리임 요구될때 ProgressDialog 같은 것을 사용 한다.
- 쓰레드를 통한 구현임으로 함수만 가져다 쓰면 간편하게 사용 할 수 있다.

-Java 소스

public class ProgressDialogActivity extends Activity implements OnClickListener {
ProgressDialog dialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

Button btn = (Button) this.findViewById(R.id.btn);
btn.setOnClickListener(this);
}

@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
timeThread();
}

public void timeThread() {

dialog = new ProgressDialog(this);
dialog = new ProgressDialog(this);
dialog.setTitle("Wait...");
dialog.setMessage("Please wait while loading...");
dialog.setIndeterminate(true);
dialog.setCancelable(true);
dialog.show();
new Thread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
try {
Thread.sleep(5000);
} catch (Throwable ex) {
ex.printStackTrace();
}
dialog.dismiss();
}
}).start();
}



- 실행 화면 


댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함