안드로이드 개발 질문/답변
(글 수 45,052)
alertdialog 생성을 해야 하는데 .. 이것은 activity를 상속받은 클래스안에 있어야 되는 건가요???
05-06 22:27:55.529: ERROR/AndroidRuntime(29246): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
계속 위 에러가 뜨는 것은 제가 무엇을 잘못했길래 뜨는 것인지 모르겠습니다.
AlertDialog alertDialogBuilder = new AlertDialog.Builder(this.getContext());
LayoutInflateralertInflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = alertInflater.inflate(R.layout.custom_dialog,(ViewGroup) findViewById(R.id.layout_root));
alertDialogBuilder.setTitle(title);
alertDialogBuilder.setView(layout);
alertDialogBuilder.setMessage(message);
alertDialogBuilder.setNeutralButton(button1String, new DialogInterface.OnClickListener() {
public void onClick( DialogInterface dialog, int which) {
dialog.dismiss(); //닫기
}
});
AlertDialog ad = alertDialogBuilder.create();
ad.show();
제가 작성한 코드는 이것인데요... 계속 저 위에 에러가 뜨는 것은 어떤 에러인지 궁금합니다.
흑흑....