當我點擊按鈕創建對話框時,出現錯誤。如何在點擊按鈕時顯示對話框?當我點擊按鈕創建對話框時,出現錯誤。如何在點擊按鈕時顯示對話框?
我的主類擴展了Activity。
deleteentry.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
new deleteOptionsDialog(getApplicationContext()).show();
}
});
public class deleteOptionsDialog extends Dialog {
public deleteOptionsDialog(final Context context) {
super(context, android.R.style.Theme_Translucent);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.delete_options_dialog);
RelativeLayout cameraLayout = (RelativeLayout) findViewById(R.id.rldelete);
cameraLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
}
});
}
您正在收到什麼錯誤? –
您的問題**如何在按鈕單擊**時調用對話框方法,但是在您的代碼中,您可以在「RelativeLayout」中實現點擊。你在哪裏按鈕? –
see here http://stackoverflow.com/questions/2634991/android-1-6-android-view-windowmanagerbadtokenexception-unable-to-add-window and http://stackoverflow.com/questions/4487491/android-unable -to-add-window-token-null-is-not-for-an-an應用程序和http://stackoverflow.com/questions/5796611/dialog-throwing-unable-to-add-window-token-null-is -not-for-an-application-wi和這裏http://stackoverflow.com/questions/18662239/android-view-windowmanagerbadtokenexception-unable-to-add-window-on-buider-s ... –