custom alertdialog 를 만들고 있는데요.


메인 activity -> 또다른 activity start -> custom alertdialog

이러한 식으로 alert 를 호출하고 있습니다.


public class SetDevice extends Activity {

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.layout_setdevice);

Button selected_device = (Button)findViewById(R.id.selectdevice);

selected_device.setOnClickListener(new Click_SelectedDevice());

}

public class Click_SelectedDevice implements OnClickListener {

@Override

public void onClick(View v) {

Context mContext5 = getApplicationContext();

LayoutInflater inflater5 = (LayoutInflater)mContext5.getSystemService(LAYOUT_INFLATER_SERVICE);

            View layout5 = inflater5.inflate(R.layout.bluetoothdevice_list,(ViewGroup)findViewById(R.id.list_layout33));

AlertDialog.Builder aDialog = new AlertDialog.Builder(getApplicationContext());

aDialog.setTitle("장비목록");

aDialog.setView(layout5);

aDialog.setPositiveButton("확인", new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

        }

   });

AlertDialog ad5 = aDialog.create();

            ad5.show(); 

}

}

}


이러한 에러가 납니다. 


05-16 14:56:45.957: E/AndroidRuntime(1305): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

05-16 14:56:45.957: E/AndroidRuntime(1305): at android.view.ViewRootImpl.setView(ViewRootImpl.java:519)


디버깅을 해보니깐....

layout5 에 여러 값들중에 상당량이 null 값이 들어가더라고요... 왜 이러는지 모르겠네요...ㅜㅜ

메인 다이얼로그에서는 저런 방법으로 많이 사용해서 잘되는데 저기서만 저러네요...ㅜㅜ

왜 그럴까요? ㅜㅜ

호출된 activity에서 cusom alertdialog 를 띄우려면 뭔가 방법이 다른가요? ㅜㅜ