안드로이드 개발 질문/답변
(글 수 45,052)
이런식으로요
레이아웃으로 만들어서 Dialog에 넣어야 될꺼 같은뎀...들어가는 방법이 있을까용
레이아웃으로 만들어서 Dialog에 넣어야 될꺼 같은뎀...들어가는 방법이 있을까용
2010.03.30 11:40:40
//
// Dialog Builder를 선언
//
AlertDialog.Builder builder;
//
// 사용할 Dialog를 선언
//
AlertDialog alertDialog;
//
// Context를 가져옴.
//
Context mContext = getApplicationContext();
//
// Layout Inflater로 View를 가져옴.
//
LayoutInflater inflater
= (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER);
View layout = inflater.inflate(R.layout.custom_dialog, null);
//
// Layout에 있는 TextView및 ImageView에 아이콘 및 Text지정
//
TextView text = (TextView) layout.findViewById(R.id.text);
text.setText("Hello, this is a custom dialog!");
ImageView image = (ImageView) layout.findViewById(R.id.image);
image.setImageResource(R.drawable.android);
//
// Dialog Builder에 Layout View를 할당.
//
builder = new AlertDialog.Builder(mContext);
builder.setView(layout);
//
// Custom Dialog Display
//
alertDialog = builder.create();
alertDialog.show();
이렇게 하고 layout에 TextView와 ImageView를 넣어서 하시면 될듯