티스토리 뷰

http://developer.android.com/guide/topics/ui/dialogs.html

싸이트에 가면

Creating a Custom Dialog의 예제에 소스가

Context mContext = getApplicationContext(); 
Dialog dialog = new Dialog(mContext);
 
 
dialog
.setContentView(R.layout.custom_dialog); 
dialog
.setTitle("Custom Dialog"); 
 
TextView text = (TextView) dialog.findViewById(R.id.text); 
text
.setText("Hello, this is a custom dialog!"); 
ImageView image = (ImageView) dialog.findViewById(R.id.image); 
image
.setImageResource(R.drawable.android);

이렇게 돼있다.
근데 실제 이렇게 돼있는거 실행하면 에러나면서 프로그램이 꺼진다.

그래서 위의
Context mContext = getApplicationContext(); 
Dialog dialog = new Dialog(mContext); 

부분을
Dialog dialog = new Dialog(this); 로 바꿔줬더니 잘 되더라.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
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
글 보관함