새로운 Activity를 띄우지 않고 Windows의 팝업 창처럼 그냥 창을 띄워 상태 알람/진행을 표시하는 녀석이다.
아래 Sample은 각각 종류별로 정리했다. 종류는 아래와 같다.
- Basic Alert - 아주 기본적인 Alert Dialog
- Button add - Dialog 창에 Button이 추가
- List type - 여러가지 항목을 선택
- CheckBox type - CheckBox가 포함
- RadioButton type - RadioButton이 포함(미리 체크 항목을 선택 할 수 있음)
- ProgressDialog type - 동그란 에니메이션이 동작함
- ProgressBar type - 막대 형태로 진행 상태를 표시함
- Custom Dialog - 임의 디자인을 적용
1. Basic Alert
AlertDialog.Builder ab = null; |
2. Button add
AlertDialog.Builder builder = new AlertDialog.Builder(this); |
3. List type
final CharSequence[] items = {"Red", "Green", "Blue"}; |
4. RadioButtons type
final CharSequence[] items = {"Red", "Green", "Blue"}; |
5. Checkboxes type
final CharSequence[] items = {"Red", "Green", "Blue"}; |
6. ProgressDialog type
private class ProgressDialogStop extends Thread |
ProgressDialog dialog = ProgressDialog.show(AlertDialogTest.this, "", |
7. ProgressBar type
private class ProgressBarStop extends Thread |
ProgressDialog progressDialog = null; |
8. CustomDialog type
별도 Dialog 타입 Layout을 설정해야 한다. <?xml version="1.0" encoding="utf-8"?> |
import android.app.Dialog;
|
Dialog dialog = new MyCustomDialog(this); |
9. CustomDialog type 2
위 8번 내용을 그대로 사용.
AlertDialog.Builder md = new AlertDialog.Builder(this); |
출처 : http://utime.blog.me/150091024547
[출처] android : Alert Dialog Sample|작성자 시간한줌
'Android' 카테고리의 다른 글
안드로이드 풀소스 코드 다운 및 빌드 방법 (0) | 2012.05.15 |
---|---|
Windows 에서 Android 풀소스 다운받기 (0) | 2012.05.15 |
User Library 빌드시 out of heap 메시지 뜨는 현상 (0) | 2012.05.01 |
SurfaceView & Double Buffering (0) | 2012.04.30 |
안드로이드란? (0) | 2009.09.14 |