Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- oracle
- 메소드
- JSP
- Graphic
- 에러페이지
- 생성자
- 기본
- 클래스
- HTML
- Android
- 전화걸기
- struts2
- 배열
- paint
- layout
- AWT
- JavaScript
- 국제화
- mybatis
- 메서드
- Menu
- 안드로이드
- 이클립스
- Eclips
- Spring
- OGNL
- 오버로딩
- 어노테이션
- 예외처리
- Java
Archives
- Today
- Total
note
Message 팝업창 띄우기 경고창,토스트 표시,Progress Dialog 본문
일반적으로
Toast(토스트) 메세지는 꼭 볼 필요 없는 메세지를 전달할때 사용하고
Alert (경고창)은 무조건 보여주어야 하는 메세지를 전달할때 사용한다
Progress Dialog는 어떠한 데이터를 가지고 오는데 사용
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/alert" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="경고창 띄우기" /> <Button android:id="@+id/toast" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Toast 표시" /> <Button android:id="@+id/progress" android:text="ProgressDialog 표시" android:layout_width="fill_parent" android:layout_height="wrap_content" /> </LinearLayout>
package com.commonsware.android.messages;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class MessageDemo extends Activity implements View.OnClickListener{
Button alert, toast, progress;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
alert=(Button)findViewById(R.id.alert);
alert.setOnClickListener(this);
toast=(Button)findViewById(R.id.toast);
toast.setOnClickListener(this);
progress=(Button)findViewById(R.id.progress);
progress.setOnClickListener(this);
}
public void onClick(View view){
if(view==alert){
new AlertDialog.Builder(this)
.setTitle("에헴...")
.setMessage("뭘봐?")
.setNeutralButton("닫기",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
// 기본적으로 창은 닫히고 추가 작업은 없다(닫히면서 행해지는 것)
}
})
.show();
}
else if(view==toast){
Toast
.makeText(this,"토스트 메세지",Toast.LENGTH_SHORT)
.show();
}else{
final ProgressDialog dialog =
//Context context : 실행중인 Activity객체
//CharSequence title : 제목
//CharSequence message : 메세지
//boolean indeterminate : 원형 아이콘 또는 막대형태의 아이콘의 실행을 유한/무한
//으로 지정할때 사용하는데 , 원형 아이콘일 경우는 무한만 설정됨 막대형태의 아이콘일만 유한/무한 설정 가능
ProgressDialog.show(this,"사이트 접속중"," 잠시만 기다려 주세요^,.^",true);
//익명내부 클래스 형태의 스레드 생성
new Thread(){
public void run(){
try{
sleep(3000);
}catch(InterruptedException e){
e.printStackTrace();
}
//찿ㅇ 중지
dialog.dismiss();
}
}.start();
}
}
}
'Android > 기본' 카테고리의 다른 글
Handler 사용하기 (로딩 표시?) (0) | 2012.01.11 |
---|---|
Activity 생명주기 (0) | 2012.01.11 |
ConText Menu 메뉴 (길게 터치시 팝업메뉴) (0) | 2012.01.11 |
Menu Xml (새로운 xml 파일 만들어 연결하기) 인플레이션 (0) | 2012.01.11 |
메뉴 Menu (0) | 2012.01.11 |